From 615fa9b5fc81ff4d4a834013ac1745a6e38dd85b Mon Sep 17 00:00:00 2001 From: Vladimir Dubrovin <3proxy@3proxy.ru> Date: Fri, 23 Oct 2026 16:23:04 +0300 Subject: [PATCH] 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 --- src/common.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/common.c b/src/common.c index 8fa14bb..d6c942b 100644 --- a/src/common.c +++ b/src/common.c @@ -426,11 +426,18 @@ int #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){ - 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){ - 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){ return recv(s, buf, len, flags);