Send() and Receive() select notified the wrong socket about readability

respectively writability.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25069 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2008-04-20 02:59:23 +00:00
parent 17619433ba
commit 61ef761d69
@@ -462,9 +462,12 @@ UnixEndpoint::Send(net_buffer *buffer)
fifoLocker.Unlock();
locker.Lock();
bool peerLocked = (fPeerEndpoint == peerEndpoint
&& _LockConnectedEndpoints(locker, peerLocker) == B_OK);
// send notifications
if (notifyRead)
gSocketModule->notify(socket, B_SELECT_READ, readable);
if (peerLocked && notifyRead)
gSocketModule->notify(peerEndpoint->socket, B_SELECT_READ, readable);
if (notifyWrite)
gSocketModule->notify(socket, B_SELECT_WRITE, writable);
@@ -517,6 +520,9 @@ UnixEndpoint::Receive(size_t numBytes, uint32 flags, net_buffer **_buffer)
if (fReceiveFifo == NULL)
RETURN_ERROR(ENOTCONN);
UnixEndpoint* peerEndpoint = fPeerEndpoint;
Reference<UnixEndpoint> peerReference(peerEndpoint);
// lock our FIFO
UnixFifo* fifo = fReceiveFifo;
Reference<UnixFifo> _(fifo);
@@ -542,11 +548,15 @@ UnixEndpoint::Receive(size_t numBytes, uint32 flags, net_buffer **_buffer)
fifoLocker.Unlock();
locker.Lock();
UnixEndpointLocker peerLocker;
bool peerLocked = (peerEndpoint != NULL && fPeerEndpoint == peerEndpoint
&& _LockConnectedEndpoints(locker, peerLocker) == B_OK);
// send notifications
if (notifyRead)
gSocketModule->notify(socket, B_SELECT_READ, readable);
if (notifyWrite)
gSocketModule->notify(socket, B_SELECT_WRITE, writable);
if (peerLocked && notifyWrite)
gSocketModule->notify(peerEndpoint->socket, B_SELECT_WRITE, writable);
switch (error) {
case UNIX_FIFO_SHUTDOWN:
@@ -630,7 +640,7 @@ UnixEndpoint::SetReceiveBufferSize(size_t size)
status_t
UnixEndpoint::Shutdown(int direction)
{
TRACE("[%ld] %p->UnixEndpoint::SetReceiveBufferSize(%d)\n",
TRACE("[%ld] %p->UnixEndpoint::Shutdown(%d)\n",
find_thread(NULL), this, direction);
uint32 shutdown;