Author: bonefish Date: 2011-06-07 18:35:49 +0200 (Tue, 07 Jun 2011) New Revision: 42009 Changeset: https://dev.haiku-os.org/changeset/42009 Modified: haiku/trunk/src/kits/network/libnetapi/NetEndpoint.cpp Log: * Added TODOs where IsDataPending() is called incorrectly. Since it has stupid semantics, I'd recommend introducing an _IsDataPending() with sane semantics and use that. * IsDataPending() Added TODO regarding possible overflow. * SetTimeout(): Added TODO regarding consistency. Modified: haiku/trunk/src/kits/network/libnetapi/NetEndpoint.cpp =================================================================== --- haiku/trunk/src/kits/network/libnetapi/NetEndpoint.cpp 2011-06-07 16:20:18 UTC (rev 42008) +++ haiku/trunk/src/kits/network/libnetapi/NetEndpoint.cpp 2011-06-07 16:35:49 UTC (rev 42009) @@ -295,6 +295,7 @@ BNetEndpoint::SetTimeout(bigtime_t timeout) { fTimeout = timeout; + // TODO: Map value < 0 to B_INFINITE_TIMEOUT or use -1 by default. } @@ -416,6 +417,8 @@ BNetEndpoint* BNetEndpoint::Accept(int32 timeout) { + // TODO: IsDataPending() expects 0 as special value for infinite timeout, + // hence the following call is broken for timeout < 0 and timeout == 0. if (!IsDataPending(timeout < 0 ? B_INFINITE_TIMEOUT : 1000LL * timeout)) return NULL; @@ -464,6 +467,7 @@ if (timeout > 0) { tv.tv_sec = timeout / 1000000; + // TODO: A big value (e.g. B_INFINITE_TIMEOUT) will overflow! tv.tv_usec = (timeout % 1000000); } @@ -482,6 +486,8 @@ if (fSocket < 0 && _SetupSocket() != B_OK) return fStatus; + // TODO: For fTimeout == 0 this is broken as IsDataPending(0) means wait + // without timeout. Furthermore the default fTimeout is B_INFINITE_TIMEOUT. if (fTimeout >= 0 && IsDataPending(fTimeout) == false) return 0; @@ -510,6 +516,8 @@ if (fSocket < 0 && _SetupSocket() != B_OK) return fStatus; + // TODO: For fTimeout == 0 this is broken as IsDataPending(0) means wait + // without timeout. Furthermore the default fTimeout is B_INFINITE_TIMEOUT. if (fTimeout >= 0 && IsDataPending(fTimeout) == false) return 0;