* 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. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42009 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -295,6 +295,7 @@ void
|
|||||||
BNetEndpoint::SetTimeout(bigtime_t timeout)
|
BNetEndpoint::SetTimeout(bigtime_t timeout)
|
||||||
{
|
{
|
||||||
fTimeout = timeout;
|
fTimeout = timeout;
|
||||||
|
// TODO: Map value < 0 to B_INFINITE_TIMEOUT or use -1 by default.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -416,6 +417,8 @@ BNetEndpoint::Listen(int backlog)
|
|||||||
BNetEndpoint*
|
BNetEndpoint*
|
||||||
BNetEndpoint::Accept(int32 timeout)
|
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))
|
if (!IsDataPending(timeout < 0 ? B_INFINITE_TIMEOUT : 1000LL * timeout))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -464,6 +467,7 @@ BNetEndpoint::IsDataPending(bigtime_t timeout)
|
|||||||
|
|
||||||
if (timeout > 0) {
|
if (timeout > 0) {
|
||||||
tv.tv_sec = timeout / 1000000;
|
tv.tv_sec = timeout / 1000000;
|
||||||
|
// TODO: A big value (e.g. B_INFINITE_TIMEOUT) will overflow!
|
||||||
tv.tv_usec = (timeout % 1000000);
|
tv.tv_usec = (timeout % 1000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -482,6 +486,8 @@ BNetEndpoint::Receive(void* buffer, size_t length, int flags)
|
|||||||
if (fSocket < 0 && _SetupSocket() != B_OK)
|
if (fSocket < 0 && _SetupSocket() != B_OK)
|
||||||
return fStatus;
|
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)
|
if (fTimeout >= 0 && IsDataPending(fTimeout) == false)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -510,6 +516,8 @@ BNetEndpoint::ReceiveFrom(void* buffer, size_t length,
|
|||||||
if (fSocket < 0 && _SetupSocket() != B_OK)
|
if (fSocket < 0 && _SetupSocket() != B_OK)
|
||||||
return fStatus;
|
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)
|
if (fTimeout >= 0 && IsDataPending(fTimeout) == false)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user