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:
@@ -107,12 +107,15 @@ BSecureSocket::Disconnect()
|
|||||||
SSL_CTX_free(fPrivate->fCTX);
|
SSL_CTX_free(fPrivate->fCTX);
|
||||||
fPrivate->fCTX = NULL;
|
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) {
|
if (fPrivate->fBIO != NULL) {
|
||||||
BIO_free(fPrivate->fBIO);
|
BIO_free(fPrivate->fBIO);
|
||||||
fPrivate->fBIO = NULL;
|
fPrivate->fBIO = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return BSocket::Disconnect();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user