Ticket #7870: NetEndpoint.cpp.diff
File NetEndpoint.cpp.diff, 1.7 KB (added by , 13 years ago) |
---|
-
NetEndpoint.cpp
294 294 void 295 295 BNetEndpoint::SetTimeout(bigtime_t timeout) 296 296 { 297 fTimeout = timeout; 298 // TODO: Map value < 0 to B_INFINITE_TIMEOUT or use -1 by default. 297 fTimeout = timeout < 0 ? B_INFINITE_TIMEOUT : timeout; 299 298 } 300 299 301 300 … … 417 416 BNetEndpoint* 418 417 BNetEndpoint::Accept(int32 timeout) 419 418 { 420 // TODO: IsDataPending() expects 0 as special value for infinite timeout,421 // hence the following call is broken for timeout < 0 and timeout == 0.422 419 if (!IsDataPending(timeout < 0 ? B_INFINITE_TIMEOUT : 1000LL * timeout)) 423 420 return NULL; 424 421 … … 465 462 FD_ZERO(&fds); 466 463 FD_SET(fSocket, &fds); 467 464 468 if (timeout > 0) {465 if (timeout >= 0) { 469 466 tv.tv_sec = timeout / 1000000; 470 467 // TODO: A big value (e.g. B_INFINITE_TIMEOUT) will overflow! 471 468 tv.tv_usec = (timeout % 1000000); 472 469 } 473 470 474 if (select(fSocket + 1, &fds, NULL, NULL, timeout > 0 ? &tv : NULL) < 0) {471 if (select(fSocket + 1, &fds, NULL, NULL, timeout >= 0 ? &tv : NULL) < 0) { 475 472 fStatus = errno; 476 473 return false; 477 474 } … … 486 483 if (fSocket < 0 && _SetupSocket() != B_OK) 487 484 return fStatus; 488 485 489 // TODO: For fTimeout == 0 this is broken as IsDataPending(0) means wait490 // without timeout. Furthermore the default fTimeout is B_INFINITE_TIMEOUT.491 486 if (fTimeout >= 0 && IsDataPending(fTimeout) == false) 492 487 return 0; 493 488 … … 516 511 if (fSocket < 0 && _SetupSocket() != B_OK) 517 512 return fStatus; 518 513 519 // TODO: For fTimeout == 0 this is broken as IsDataPending(0) means wait520 // without timeout. Furthermore the default fTimeout is B_INFINITE_TIMEOUT.521 514 if (fTimeout >= 0 && IsDataPending(fTimeout) == false) 522 515 return 0; 523 516