protocols/unix: Implement MSG_NOSIGNAL.

Same logic as in the TCP protocol module.

This fixes a regression from hrev57383: curl now works
again. (Perhaps it shouldn't be called a "regression",
though, but instead an uncovered bug / missing feature.)

Fixes #18666.
This commit is contained in:
Augustin Cavalier
2023-11-16 12:08:47 -05:00
parent 74a44f5aed
commit 3bae07fc29
2 changed files with 4 additions and 4 deletions
@@ -215,7 +215,7 @@ UnixDatagramEndpoint::Send(const iovec* vecs, size_t vecCount,
TRACE("[%" B_PRId32 "] %p->UnixDatagramEndpoint::Send()\n", TRACE("[%" B_PRId32 "] %p->UnixDatagramEndpoint::Send()\n",
find_thread(NULL), this); find_thread(NULL), this);
if ((flags & ~(MSG_DONTWAIT)) != 0) if ((flags & ~(MSG_DONTWAIT | MSG_NOSIGNAL)) != 0)
return EOPNOTSUPP; return EOPNOTSUPP;
bigtime_t timeout = 0; bigtime_t timeout = 0;
@@ -307,7 +307,7 @@ UnixDatagramEndpoint::Send(const iovec* vecs, size_t vecCount,
switch (result) { switch (result) {
case EPIPE: case EPIPE:
if (gStackModule->is_syscall()) if (gStackModule->is_syscall() && (flags & MSG_NOSIGNAL) == 0)
send_signal(find_thread(NULL), SIGPIPE); send_signal(find_thread(NULL), SIGPIPE);
break; break;
case B_TIMED_OUT: case B_TIMED_OUT:
@@ -379,7 +379,7 @@ UnixStreamEndpoint::Send(const iovec* vecs, size_t vecCount,
TRACE("[%" B_PRId32 "] %p->UnixStreamEndpoint::Send(%p, %ld, %p)\n", TRACE("[%" B_PRId32 "] %p->UnixStreamEndpoint::Send(%p, %ld, %p)\n",
find_thread(NULL), this, vecs, vecCount, ancillaryData); find_thread(NULL), this, vecs, vecCount, ancillaryData);
if ((flags & ~(MSG_DONTWAIT)) != 0) if ((flags & ~(MSG_DONTWAIT | MSG_NOSIGNAL)) != 0)
return EOPNOTSUPP; return EOPNOTSUPP;
bigtime_t timeout = 0; bigtime_t timeout = 0;
@@ -454,7 +454,7 @@ UnixStreamEndpoint::Send(const iovec* vecs, size_t vecCount,
case EPIPE: case EPIPE:
// The peer closed connection or shutdown its read side. Reward // The peer closed connection or shutdown its read side. Reward
// the caller with a SIGPIPE. // the caller with a SIGPIPE.
if (gStackModule->is_syscall()) if (gStackModule->is_syscall() && (flags & MSG_NOSIGNAL) == 0)
send_signal(find_thread(NULL), SIGPIPE); send_signal(find_thread(NULL), SIGPIPE);
break; break;
case B_TIMED_OUT: case B_TIMED_OUT: