fix race condition

This commit is contained in:
walker0643 2018-02-01 16:37:25 -05:00
parent 830f6acbef
commit b3298ad799
1 changed files with 8 additions and 1 deletions

View File

@ -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);
}
}