Changeset 12598 for trunk/Cosy/tcpip/MTcpIpIO.cc
- Timestamp:
- 11/21/11 13:08:27 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cosy/tcpip/MTcpIpIO.cc
r10031 r12598 62 62 } 63 63 64 MTcpIp IO::MTcpIpIO(const char *addr, Int_t tx, Int_t rx, UInt_t timeout) : MTcpIpI(rx, timeout), MTcpIpO(addr, tx)64 MTcpIpCC::MTcpIpCC(Int_t rx, UInt_t timeout) : MTcpIpI(rx, timeout) 65 65 { 66 66 MTcpIpI::RunThread(); 67 } 68 69 MTcpIpIO::MTcpIpIO(const char *addr, Int_t tx, Int_t rx, UInt_t timeout) : MTcpIpCC(rx, timeout), MTcpIpO(addr, tx) 70 { 67 71 } 68 72 … … 277 281 } 278 282 279 bool MTcpIp IO::InterpreteStr(TString str)283 bool MTcpIpCC::InterpreteStr(TString str) 280 284 { 281 285 cout << "Rx: " << str << flush; … … 283 287 } 284 288 285 Bool_t MTcpIp IO::ReadSocket(TSocket &rx)289 Bool_t MTcpIpCC::ReadSocket(TSocket &rx) 286 290 { 287 291 TString str; … … 308 312 309 313 // Data received (len==1) 310 if (c!='\n' )314 if (c!='\n' && c!=0) 311 315 { 312 316 str += c; … … 331 335 } 332 336 337 fRxMutex.Lock(); 338 333 339 fConnectionEstablished = kTRUE; 340 fRxSocket = &sock; 341 342 fRxMutex.UnLock(); 334 343 335 344 MTimeout timeout(fTimeout); … … 409 418 gLog << all << MTime(-1) << " Connection established to " << MTcpIpO::GetSocketAddress(*socket) << "..." << endl; 410 419 411 if (!WaitForData(*socket)) 412 fConnectionEstablished = kFALSE; 420 WaitForData(*socket); 421 422 fRxMutex.Lock(); 423 424 fRxSocket = 0; 425 fConnectionEstablished = kFALSE; 426 427 fRxMutex.UnLock(); 413 428 414 429 #ifdef DEBUG … … 455 470 456 471 return 0; 472 } 473 474 bool MTcpIpFact::Send(const char *msg, int len) 475 { 476 const Int_t mtx = fRxMutex.TryLock(); 477 if (mtx==13) 478 gLog << warn << "MTcpIpO::Send - mutex is already locked by this thread." << endl; 479 480 // If Mutex cannot be locked, i.e. we are currently reopening 481 // the send socket we cannot wait, because we would block the 482 // executing threrad. 483 if (mtx) 484 return false; 485 486 const bool rc = fRxSocket ? MTcpIpO::SendFrame(*fRxSocket, msg, len) : false; 487 488 fRxMutex.UnLock(); 489 490 return rc; 457 491 } 458 492
Note:
See TracChangeset
for help on using the changeset viewer.