Sockets: sends with MSG_NOSIGNAL where the system has it

A peer gone is then an error of the send rather than SIGPIPE. SIGPIPE
stays ignored for what cannot pass the flag: TLS writes and splice().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Vladimir Dubrovin 2026-10-23 16:23:04 +03:00
parent 83d8138818
commit 30e2e34dd6

View File

@ -427,11 +427,18 @@ int
#endif #endif
} }
/* a peer gone is an error of the send, not SIGPIPE, where the system can
say so for a call: SIGPIPE is ignored too, for TLS and splice() */
#ifdef MSG_NOSIGNAL
#define SENDFLAGS MSG_NOSIGNAL
#else
#define SENDFLAGS 0
#endif
ssize_t def_send(void* state, SOCKET s, const void *msg, size_t len, int flags){ ssize_t def_send(void* state, SOCKET s, const void *msg, size_t len, int flags){
return send(s, msg, len, flags); return send(s, msg, len, flags | SENDFLAGS);
} }
ssize_t def_sendto(void* state, SOCKET s, const void *msg, size_t len, int flags, const struct sockaddr *to, socklen_t tolen){ ssize_t def_sendto(void* state, SOCKET s, const void *msg, size_t len, int flags, const struct sockaddr *to, socklen_t tolen){
return sendto(s, msg, len, flags, to, tolen); return sendto(s, msg, len, flags | SENDFLAGS, to, tolen);
} }
ssize_t def_recv(void* state, SOCKET s, void *buf, size_t len, int flags){ ssize_t def_recv(void* state, SOCKET s, void *buf, size_t len, int flags){
return recv(s, buf, len, flags); return recv(s, buf, len, flags);