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:
@@ -462,9 +462,12 @@ UnixEndpoint::Send(net_buffer *buffer)
|
|||||||
fifoLocker.Unlock();
|
fifoLocker.Unlock();
|
||||||
locker.Lock();
|
locker.Lock();
|
||||||
|
|
||||||
|
bool peerLocked = (fPeerEndpoint == peerEndpoint
|
||||||
|
&& _LockConnectedEndpoints(locker, peerLocker) == B_OK);
|
||||||
|
|
||||||
// send notifications
|
// send notifications
|
||||||
if (notifyRead)
|
if (peerLocked && notifyRead)
|
||||||
gSocketModule->notify(socket, B_SELECT_READ, readable);
|
gSocketModule->notify(peerEndpoint->socket, B_SELECT_READ, readable);
|
||||||
if (notifyWrite)
|
if (notifyWrite)
|
||||||
gSocketModule->notify(socket, B_SELECT_WRITE, writable);
|
gSocketModule->notify(socket, B_SELECT_WRITE, writable);
|
||||||
|
|
||||||
@@ -517,6 +520,9 @@ UnixEndpoint::Receive(size_t numBytes, uint32 flags, net_buffer **_buffer)
|
|||||||
if (fReceiveFifo == NULL)
|
if (fReceiveFifo == NULL)
|
||||||
RETURN_ERROR(ENOTCONN);
|
RETURN_ERROR(ENOTCONN);
|
||||||
|
|
||||||
|
UnixEndpoint* peerEndpoint = fPeerEndpoint;
|
||||||
|
Reference<UnixEndpoint> peerReference(peerEndpoint);
|
||||||
|
|
||||||
// lock our FIFO
|
// lock our FIFO
|
||||||
UnixFifo* fifo = fReceiveFifo;
|
UnixFifo* fifo = fReceiveFifo;
|
||||||
Reference<UnixFifo> _(fifo);
|
Reference<UnixFifo> _(fifo);
|
||||||
@@ -542,11 +548,15 @@ UnixEndpoint::Receive(size_t numBytes, uint32 flags, net_buffer **_buffer)
|
|||||||
fifoLocker.Unlock();
|
fifoLocker.Unlock();
|
||||||
locker.Lock();
|
locker.Lock();
|
||||||
|
|
||||||
|
UnixEndpointLocker peerLocker;
|
||||||
|
bool peerLocked = (peerEndpoint != NULL && fPeerEndpoint == peerEndpoint
|
||||||
|
&& _LockConnectedEndpoints(locker, peerLocker) == B_OK);
|
||||||
|
|
||||||
// send notifications
|
// send notifications
|
||||||
if (notifyRead)
|
if (notifyRead)
|
||||||
gSocketModule->notify(socket, B_SELECT_READ, readable);
|
gSocketModule->notify(socket, B_SELECT_READ, readable);
|
||||||
if (notifyWrite)
|
if (peerLocked && notifyWrite)
|
||||||
gSocketModule->notify(socket, B_SELECT_WRITE, writable);
|
gSocketModule->notify(peerEndpoint->socket, B_SELECT_WRITE, writable);
|
||||||
|
|
||||||
switch (error) {
|
switch (error) {
|
||||||
case UNIX_FIFO_SHUTDOWN:
|
case UNIX_FIFO_SHUTDOWN:
|
||||||
@@ -630,7 +640,7 @@ UnixEndpoint::SetReceiveBufferSize(size_t size)
|
|||||||
status_t
|
status_t
|
||||||
UnixEndpoint::Shutdown(int direction)
|
UnixEndpoint::Shutdown(int direction)
|
||||||
{
|
{
|
||||||
TRACE("[%ld] %p->UnixEndpoint::SetReceiveBufferSize(%d)\n",
|
TRACE("[%ld] %p->UnixEndpoint::Shutdown(%d)\n",
|
||||||
find_thread(NULL), this, direction);
|
find_thread(NULL), this, direction);
|
||||||
|
|
||||||
uint32 shutdown;
|
uint32 shutdown;
|
||||||
|
|||||||
Reference in New Issue
Block a user