fix: macOS server crash when client disconnects abruptly

This commit is contained in:
gayanMatch
2026-01-09 16:45:40 -07:00
committed by Nick Bolton
parent 7fdb26f2ea
commit 35ee17f959
2 changed files with 9 additions and 0 deletions

View File

@ -79,6 +79,10 @@ ArchSocket ArchNetworkBSD::newSocket(AddressFamily family, SocketType type)
}
try {
setBlockingOnSocket(fd, false);
#if defined(__APPLE__)
int on = 1;
setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &on, sizeof(on));
#endif
} catch (...) {
close(fd);
throw;
@ -196,6 +200,10 @@ ArchSocket ArchNetworkBSD::acceptSocket(ArchSocket s, ArchNetAddress *addr)
try {
setBlockingOnSocket(fd, false);
#if defined(__APPLE__)
int on = 1;
setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &on, sizeof(on));
#endif
} catch (...) {
close(fd);
delete newSocket;

View File

@ -384,6 +384,7 @@ void SecureSocket::freeSSL()
setJob(nullptr);
if (m_ssl) {
if (m_ssl->m_ssl != nullptr) {
SSL_set_quiet_shutdown(m_ssl->m_ssl, 1);
SSL_shutdown(m_ssl->m_ssl);
SSL_free(m_ssl->m_ssl);