fix: macOS server crash when client disconnects abruptly
This commit is contained in:
parent
7fdb26f2ea
commit
35ee17f959
2 changed files with 9 additions and 0 deletions
|
|
@ -79,6 +79,10 @@ ArchSocket ArchNetworkBSD::newSocket(AddressFamily family, SocketType type)
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
setBlockingOnSocket(fd, false);
|
setBlockingOnSocket(fd, false);
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
int on = 1;
|
||||||
|
setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &on, sizeof(on));
|
||||||
|
#endif
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
close(fd);
|
close(fd);
|
||||||
throw;
|
throw;
|
||||||
|
|
@ -196,6 +200,10 @@ ArchSocket ArchNetworkBSD::acceptSocket(ArchSocket s, ArchNetAddress *addr)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setBlockingOnSocket(fd, false);
|
setBlockingOnSocket(fd, false);
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
int on = 1;
|
||||||
|
setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &on, sizeof(on));
|
||||||
|
#endif
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
close(fd);
|
close(fd);
|
||||||
delete newSocket;
|
delete newSocket;
|
||||||
|
|
|
||||||
|
|
@ -384,6 +384,7 @@ void SecureSocket::freeSSL()
|
||||||
setJob(nullptr);
|
setJob(nullptr);
|
||||||
if (m_ssl) {
|
if (m_ssl) {
|
||||||
if (m_ssl->m_ssl != nullptr) {
|
if (m_ssl->m_ssl != nullptr) {
|
||||||
|
SSL_set_quiet_shutdown(m_ssl->m_ssl, 1);
|
||||||
SSL_shutdown(m_ssl->m_ssl);
|
SSL_shutdown(m_ssl->m_ssl);
|
||||||
|
|
||||||
SSL_free(m_ssl->m_ssl);
|
SSL_free(m_ssl->m_ssl);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue