From ec1f43f30465ee4700c4a8a85dfb99ad6eaf8706 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sat, 17 May 2008 18:48:24 +0000 Subject: [PATCH] axeld + bonefish: * Small style changes. * Currently ifdef'ed out potentially correct changes, that break Neon tests which otherwise succeed. Axel will investigate this further. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25530 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../network/protocols/tcp/TCPEndpoint.cpp | 36 +++++++++++++++++-- .../network/protocols/tcp/TCPEndpoint.h | 4 +-- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp b/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp index 48dc150dcf..a3ea00026f 100644 --- a/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp +++ b/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp @@ -466,7 +466,7 @@ TCPEndpoint::Close() { TRACE("Close()"); - MutexLocker lock(fLock); + MutexLocker locker(fLock); if (fState == LISTEN) delete_sem(fAcceptSemaphore); @@ -488,7 +488,7 @@ TCPEndpoint::Close() bigtime_t maximum = absolute_timeout(socket->linger * 1000000LL); while (fSendQueue.Used() > 0) { - status = fSendList.Wait(lock, maximum); + status = fSendList.Wait(locker, maximum); if (status == B_TIMED_OUT || status == B_WOULD_BLOCK) break; else if (status < B_OK) @@ -497,8 +497,22 @@ TCPEndpoint::Close() TRACE("Close(): after waiting, the SendQ was left with %lu bytes.", fSendQueue.Used()); - } +#if 0 +// TODO: For the following to work we also need to be notified when TIME_WAIT +// is entered. + } else if (fRoute != NULL && (fRoute->flags & RTF_LOCAL) != 0) { + // This is a local connection - just wait until we're done so that + // the port is available again + while (fState != CLOSED && fState != TIME_WAIT) { + if (socket->error != B_OK) + return socket->error; + status_t status = fSendList.Wait(locker); + if (status < B_OK) + return status; + } +#endif // 0 + } return B_OK; } @@ -1117,7 +1131,13 @@ TCPEndpoint::_MarkEstablished() status_t TCPEndpoint::_WaitForEstablished(MutexLocker &locker, bigtime_t timeout) { +#if 0 +// TODO: Checking for CLOSED seems correct, but breaks several neon tests. +// When investigating this, also have a look at _Close() and _HandleReset(). + while (fState < ESTABLISHED && fState != CLOSED) { +#else while (fState < ESTABLISHED) { +#endif if (socket->error != B_OK) return socket->error; @@ -1141,6 +1161,13 @@ TCPEndpoint::_Close() T(State(this)); fFlags |= FLAG_DELETE_ON_CLOSE; + +#if 0 +// TODO: Should probably be moved here (from _HandleReset()), but cf. the +// comment in _WaitForEstablished(). + fSendList.Signal(); + _NotifyReader(); +#endif } @@ -1150,8 +1177,11 @@ TCPEndpoint::_HandleReset(status_t error) socket->error = error; _Close(); +#if 1 +// TODO: Should be moved to _Close(), but cf. comment in _WaitForEstablished(). fSendList.Signal(); _NotifyReader(); +#endif gSocketModule->notify(socket, B_SELECT_WRITE, error); gSocketModule->notify(socket, B_SELECT_ERROR, error); diff --git a/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h b/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h index 11dba9161c..d0cd213d30 100644 --- a/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h +++ b/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h @@ -27,12 +27,12 @@ class WaitList { public: - WaitList(const char *name); + WaitList(const char* name); ~WaitList(); status_t InitCheck() const; - status_t Wait(MutexLocker &, bigtime_t timeout); + status_t Wait(MutexLocker& locker, bigtime_t timeout = B_INFINITE_TIMEOUT); void Signal(); private: