From 5947a3be5a902c477d00e9343dfe63ba57bdbf33 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Thu, 15 May 2008 21:05:59 +0000 Subject: [PATCH] * Fixed read() on a read-shutdown socket. It must never wait. * Added TODO regarding read/write shutdown. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25515 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp b/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp index cfcb9a0d61..1f97e5b30b 100644 --- a/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp +++ b/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp @@ -702,8 +702,11 @@ TCPEndpoint::Shutdown(int direction) if (direction == SHUT_RD || direction == SHUT_RDWR) fFlags |= FLAG_NO_RECEIVE; - if (direction == SHUT_WR || direction == SHUT_RDWR) + if (direction == SHUT_WR || direction == SHUT_RDWR) { + // TODO: That's not correct. After read/write shutting down the socket + // one should still be able to read previously arrived data. _Disconnect(false); + } return B_OK; } @@ -883,6 +886,9 @@ TCPEndpoint::ReadData(size_t numBytes, uint32 flags, net_buffer** _buffer) if ((flags & MSG_DONTWAIT) != 0 || socket->receive.timeout == 0) return B_WOULD_BLOCK; + if ((fFlags & FLAG_NO_RECEIVE) != 0) + return B_OK; + status_t status = fReceiveList.Wait(locker, timeout); if (status < B_OK) { // The Open Group base specification mentions that EINTR should be