unix: sendmsg should return EPIPE after close

https://pubs.opengroup.org/onlinepubs/9699919799/functions/sendmsg.html
"[EPIPE] ... the socket is connection-mode and is no longer connected."
Change-Id: I6728b088d2f717b769697218edf26c76c59f488e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3816
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
Jérôme Duval 2021-03-20 18:24:30 +01:00
parent f0c4b0a69a
commit 10ff9c6a14
2 changed files with 5 additions and 2 deletions

View File

@ -48,7 +48,8 @@ UnixEndpoint::UnixEndpoint(net_socket* socket)
fReceiveFifo(NULL),
fState(UNIX_ENDPOINT_CLOSED),
fAcceptSemaphore(-1),
fIsChild(false)
fIsChild(false),
fWasConnected(false)
{
TRACE("[%" B_PRId32 "] %p->UnixEndpoint::UnixEndpoint()\n",
find_thread(NULL), this);
@ -383,6 +384,7 @@ UnixEndpoint::Connect(const struct sockaddr *_address)
peerFifoDeleter.Detach();
fState = UNIX_ENDPOINT_CONNECTED;
fWasConnected = true;
gSocketModule->set_connected(newSocket);
@ -802,7 +804,7 @@ UnixEndpoint::_LockConnectedEndpoints(UnixEndpointLocker& locker,
UnixEndpointLocker& peerLocker)
{
if (fState != UNIX_ENDPOINT_CONNECTED)
RETURN_ERROR(ENOTCONN);
RETURN_ERROR(fWasConnected ? EPIPE : ENOTCONN);
// We need to lock the peer, too. Get a reference -- we might need to
// unlock ourselves to get the locking order right.

View File

@ -119,6 +119,7 @@ private:
sem_id fAcceptSemaphore;
ucred fCredentials;
bool fIsChild;
bool fWasConnected;
};
#endif // UNIX_ENDPOINT_H