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;