SecureSocket: avoid crash on close

Deleting the BIO while it's still waiting on a read() in another thread
will lead to a crash when the socket is eventually closed. Close the
socket first, so the read() is unlocked, then safely delete the BIO.
This commit is contained in:
Adrien Destugues
2014-01-06 12:48:46 +01:00
parent 27b702f11a
commit 5bdd4157d3
+4 -1
View File
@@ -107,12 +107,15 @@ BSecureSocket::Disconnect()
SSL_CTX_free(fPrivate->fCTX);
fPrivate->fCTX = NULL;
}
BSocket::Disconnect();
// Must do this before freeing the BIO, to make sure any pending
// read or write gets unlocked properly.
if (fPrivate->fBIO != NULL) {
BIO_free(fPrivate->fBIO);
fPrivate->fBIO = NULL;
}
}
return BSocket::Disconnect();
}