- Timestamp:
- 05/25/11 16:26:56 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/ftm.cc
r10748 r10823 57 57 } 58 58 59 ba::deadline_timer deadline_;60 61 59 ba::deadline_timer fTriggerDynData; 62 60 63 61 // The constructor is prvate to force the obtained pointer to be shared 64 62 tcp_connection(ba::io_service& ioservice) : ba::ip::tcp::socket(ioservice), 65 deadline_(ioservice),fTriggerDynData(ioservice)66 { 67 deadline_.expires_at(boost::posix_time::pos_infin);63 fTriggerDynData(ioservice) 64 { 65 //deadline_.expires_at(boost::posix_time::pos_infin); 68 66 69 67 fHeader.fDelimiter=kDelimiterStart; … … 178 176 fHeader.fDataSize=sizeof(FTM::DynamicData)/2+1; 179 177 fHeader.fTriggerCounter = fCounter++; 180 fHeader.fTimeStamp = fTimeStamp++ ;//lrint(Time().UnixTime());178 fHeader.fTimeStamp = fTimeStamp++*1000000;//lrint(Time().UnixTime()); 181 179 182 180 fBufHeader = fHeader.HtoN(); … … 193 191 fHeader.fDataSize=sizeof(FTM::StaticData)/2+1; 194 192 fHeader.fTriggerCounter = fCounter++; 195 fHeader.fTimeStamp = fTimeStamp ;//lrint(Time().UnixTime());193 fHeader.fTimeStamp = fTimeStamp*1000000;//lrint(Time().UnixTime()); 196 194 197 195 for (int i=0; i<4; i++) … … 213 211 // Close the connection 214 212 close(); 215 deadline_.cancel();216 213 return; 217 214 } … … 246 243 fHeader.fDataSize=sizeof(FTM::FtuList)/2+1; 247 244 fHeader.fTriggerCounter = fCounter++; 248 fHeader.fTimeStamp = fTimeStamp ;//lrint(Time().UnixTime());245 fHeader.fTimeStamp = fTimeStamp*1000000;//lrint(Time().UnixTime()); 249 246 250 247 fFtuList[1].fPingAddr = ((rand()&1)<<9) | 1; … … 369 366 fHeader.fDataSize=2; 370 367 fHeader.fTriggerCounter = fCounter++; 371 fHeader.fTimeStamp = fTimeStamp ;//lrint(Time().UnixTime());368 fHeader.fTimeStamp = fTimeStamp*1000000;//lrint(Time().UnixTime()); 372 369 373 370 fBufHeader = fHeader.HtoN(); … … 410 407 } 411 408 412 void check_deadline(const boost::system::error_code &)409 void SendDynData(const boost::system::error_code &) 413 410 { 414 411 if (!is_open()) … … 419 416 } 420 417 418 if (ec==ba::error::basic_errors::operation_aborted) 419 return; 420 421 421 // Check whether the deadline has passed. We compare the deadline 422 422 // against the current time since a new asynchronous operation 423 423 // may have moved the deadline before this actor had a chance 424 424 // to run. 425 if (deadline_.expires_at() <= ba::deadline_timer::traits_type::now()) 426 { 427 // The deadline has passed. Stop the session. The other 428 // actors will terminate as soon as possible. 429 // AsyncWrite(ba::buffer(ba::const_buffer(&fHeader, sizeof(FTM::Header)))); 430 // AsyncWait(deadline_, 3, &tcp_connection::check_deadline); 431 432 return; 433 } 434 435 AsyncWait(deadline_, 3, &tcp_connection::check_deadline); 436 } 437 438 void SendDynData(const boost::system::error_code &) 439 { 440 if (!is_open()) 441 { 442 // For example: Here we could schedule a new accept if we 443 // would not want to allow two connections at the same time. 444 return; 445 } 446 447 // Check whether the deadline has passed. We compare the deadline 448 // against the current time since a new asynchronous operation 449 // may have moved the deadline before this actor had a chance 450 // to run. 451 if (deadline_.expires_at() <= ba::deadline_timer::traits_type::now()) 425 426 if (fTriggerDynData.expires_at() > ba::deadline_timer::traits_type::now()) 452 427 return; 453 428 … … 456 431 457 432 AsyncWait(fTriggerDynData, 1, &tcp_connection::SendDynData); 458 return;459 433 } 460 434
Note:
See TracChangeset
for help on using the changeset viewer.