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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0121tAhQVe4qbCwYgVjKQS4B
This commit is contained in:
1 parent
4918654715
commit
c0e1d87ac1
1 file changed
+11
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user