mirror of
https://github.com/debauchee/barrier.git
synced 2024-12-23 19:12:14 +03:00
Fix memory leak during socket shutdown
This commit is contained in:
parent
4ec30b6ade
commit
71f2ca7c35
@ -84,16 +84,8 @@ SecureSocket::~SecureSocket()
|
||||
// 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);
|
||||
freeSSLResources();
|
||||
|
||||
SSL_free(m_ssl->m_ssl);
|
||||
m_ssl->m_ssl = NULL;
|
||||
}
|
||||
if (m_ssl->m_context != NULL) {
|
||||
SSL_CTX_free(m_ssl->m_context);
|
||||
m_ssl->m_context = NULL;
|
||||
}
|
||||
// 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);
|
||||
@ -104,12 +96,24 @@ void
|
||||
SecureSocket::close()
|
||||
{
|
||||
isFatal(true);
|
||||
|
||||
SSL_shutdown(m_ssl->m_ssl);
|
||||
|
||||
freeSSLResources();
|
||||
TCPSocket::close();
|
||||
}
|
||||
|
||||
void SecureSocket::freeSSLResources()
|
||||
{
|
||||
if (m_ssl->m_ssl != NULL) {
|
||||
SSL_shutdown(m_ssl->m_ssl);
|
||||
SSL_free(m_ssl->m_ssl);
|
||||
m_ssl->m_ssl = NULL;
|
||||
}
|
||||
|
||||
if (m_ssl->m_context != NULL) {
|
||||
SSL_CTX_free(m_ssl->m_context);
|
||||
m_ssl->m_context = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SecureSocket::connect(const NetworkAddress& addr)
|
||||
{
|
||||
|
@ -88,6 +88,8 @@ private:
|
||||
|
||||
void handleTCPConnected(const Event& event, void*);
|
||||
|
||||
void freeSSLResources();
|
||||
|
||||
private:
|
||||
Ssl* m_ssl;
|
||||
bool m_secureReady;
|
||||
|
Loading…
Reference in New Issue
Block a user