From c0e1d87ac1715a437020d1f5867a790ac2fb4b3a Mon Sep 17 00:00:00 2001 From: Brad Arant Date: Mon, 2 Nov 2026 08:57:23 -0800 Subject: [PATCH] Ignore SIGPIPE process-wide in EPoll Writing to a socket the peer has already reset raises SIGPIPE, whose default action kills the whole process. Socket.cpp carried a sigpipe_handler but nothing ever installed it. OpenSSL's SSL_write() calls write() itself, so MSG_NOSIGNAL can't cover TLS - ignore the signal once for every server built on EPoll. Reproduced: a burst of TLS clients disconnecting mid-session killed the server within a few rounds. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0121tAhQVe4qbCwYgVjKQS4B --- EPoll.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/EPoll.cpp b/EPoll.cpp index 13528d6..3c14cee 100644 --- a/EPoll.cpp +++ b/EPoll.cpp @@ -11,6 +11,17 @@ namespace core { coreutils::Log(coreutils::LOG_DEBUG_2) << "EPoll starting."; + // Writing to a socket whose peer has already reset it raises + // SIGPIPE, and the default action terminates the whole process - + // every connection, not just the dead one. Socket.cpp has carried a + // sigpipe_handler for this but nothing ever installed it. Plain + // writes could use MSG_NOSIGNAL, but OpenSSL's SSL_write() calls + // write() itself, so the signal has to be ignored process-wide; the + // failed write then just returns EPIPE and that one connection is + // closed normally. Reproduced: a burst of STARTTLS clients + // disconnecting mid-session killed the server within a few rounds. + signal(SIGPIPE, SIG_IGN); + maxSockets = 1000; epfd = epoll_create1(0); terminateThreads = false;