Ticket #7870: NetEndpoint.cpp.diff

File NetEndpoint.cpp.diff, 1.7 KB (added by Duggan, 13 years ago)

diff of changes made to fix this ticket

  • NetEndpoint.cpp

     
    294294void
    295295BNetEndpoint::SetTimeout(bigtime_t timeout)
    296296{
    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;
    299298}
    300299
    301300
     
    417416BNetEndpoint*
    418417BNetEndpoint::Accept(int32 timeout)
    419418{
    420     // TODO: IsDataPending() expects 0 as special value for infinite timeout,
    421     // hence the following call is broken for timeout < 0 and timeout == 0.
    422419    if (!IsDataPending(timeout < 0 ? B_INFINITE_TIMEOUT : 1000LL * timeout))
    423420        return NULL;
    424421
     
    465462    FD_ZERO(&fds);
    466463    FD_SET(fSocket, &fds);
    467464
    468     if (timeout > 0) {
     465    if (timeout >= 0) {
    469466        tv.tv_sec = timeout / 1000000;
    470467            // TODO: A big value (e.g. B_INFINITE_TIMEOUT) will overflow!
    471468        tv.tv_usec = (timeout % 1000000);
    472469    }
    473470
    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) {
    475472        fStatus = errno;
    476473        return false;
    477474    }
     
    486483    if (fSocket < 0 && _SetupSocket() != B_OK)
    487484        return fStatus;
    488485
    489     // TODO: For fTimeout == 0 this is broken as IsDataPending(0) means wait
    490     // without timeout. Furthermore the default fTimeout is B_INFINITE_TIMEOUT.
    491486    if (fTimeout >= 0 && IsDataPending(fTimeout) == false)
    492487        return 0;
    493488
     
    516511    if (fSocket < 0 && _SetupSocket() != B_OK)
    517512        return fStatus;
    518513
    519     // TODO: For fTimeout == 0 this is broken as IsDataPending(0) means wait
    520     // without timeout. Furthermore the default fTimeout is B_INFINITE_TIMEOUT.
    521514    if (fTimeout >= 0 && IsDataPending(fTimeout) == false)
    522515        return 0;
    523516