From b3298ad799afde84edd45d9ea81482f72609315d Mon Sep 17 00:00:00 2001 From: walker0643 <> Date: Thu, 1 Feb 2018 16:37:25 -0500 Subject: [PATCH] fix race condition --- src/lib/net/SecureSocket.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/net/SecureSocket.cpp b/src/lib/net/SecureSocket.cpp index 5c892524..d8b76d3f 100644 --- a/src/lib/net/SecureSocket.cpp +++ b/src/lib/net/SecureSocket.cpp @@ -77,6 +77,10 @@ SecureSocket::SecureSocket( SecureSocket::~SecureSocket() { isFatal(true); + // take socket from multiplexer ASAP otherwise the race condition + // could cause events to get called on a dead object. TCPSocket + // will do this, too, but the double-call is harmless + setJob(NULL); if (m_ssl->m_ssl != NULL) { SSL_shutdown(m_ssl->m_ssl); @@ -87,7 +91,9 @@ SecureSocket::~SecureSocket() SSL_CTX_free(m_ssl->m_context); m_ssl->m_context = NULL; } - ARCH->sleep(1); + // removing sleep() because I have no idea why you would want to do it + // ... smells of trying to cover up a bug you don't understand + //ARCH->sleep(1); delete m_ssl; } @@ -403,6 +409,7 @@ SecureSocket::createSSL() // I assume just one instance is needed // get new SSL state with context if (m_ssl->m_ssl == NULL) { + assert(m_ssl->m_context != NULL); m_ssl->m_ssl = SSL_new(m_ssl->m_context); } }