#6525 Removed sleep before TLS socket delete, and fix race condition by removing socket from job queue

This commit is contained in:
walker0643 2018-02-01 16:37:25 -05:00 committed by Jnewbon
parent 01033d730f
commit 30c6b3a588
1 changed files with 5 additions and 1 deletions

View File

@ -76,6 +76,10 @@ SecureSocket::SecureSocket(IEventQueue* events,
SecureSocket::~SecureSocket() SecureSocket::~SecureSocket()
{ {
isFatal(true); 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) { if (m_ssl->m_ssl != NULL) {
SSL_shutdown(m_ssl->m_ssl); SSL_shutdown(m_ssl->m_ssl);
@ -86,7 +90,6 @@ SecureSocket::~SecureSocket()
SSL_CTX_free(m_ssl->m_context); SSL_CTX_free(m_ssl->m_context);
m_ssl->m_context = NULL; m_ssl->m_context = NULL;
} }
ARCH->sleep(1);
delete m_ssl; delete m_ssl;
} }
@ -408,6 +411,7 @@ SecureSocket::createSSL()
// I assume just one instance is needed // I assume just one instance is needed
// get new SSL state with context // get new SSL state with context
if (m_ssl->m_ssl == NULL) { if (m_ssl->m_ssl == NULL) {
assert(m_ssl->m_context != NULL);
m_ssl->m_ssl = SSL_new(m_ssl->m_context); m_ssl->m_ssl = SSL_new(m_ssl->m_context);
} }
} }