summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2012-01-26 01:36:41 -0500
committerEliot Horowitz <eliot@10gen.com>2012-01-26 01:36:41 -0500
commitab1e828dd777945a0afe67c66c37ca2deb2c6ee1 (patch)
treeb24fa84c6e568d35b4216a3c02bd1b320d20a009
parent076f88cf6fe68d1ae5a404934e5cd492f1436352 (diff)
downloadmongo-ab1e828dd777945a0afe67c66c37ca2deb2c6ee1.tar.gz
fix ssl mem leak
-rw-r--r--util/net/sock.cpp21
-rw-r--r--util/net/sock.h2
2 files changed, 14 insertions, 9 deletions
diff --git a/util/net/sock.cpp b/util/net/sock.cpp
index 7b7728909aa..ac565c3d234 100644
--- a/util/net/sock.cpp
+++ b/util/net/sock.cpp
@@ -479,13 +479,18 @@ namespace mongo {
_bytesOut = 0;
_bytesIn = 0;
#ifdef MONGO_SSL
+ _ssl = 0;
_sslAccepted = 0;
#endif
}
void Socket::close() {
#ifdef MONGO_SSL
- _ssl.reset();
+ if ( _ssl ) {
+ SSL_shutdown( _ssl );
+ SSL_free( _ssl );
+ _ssl = 0;
+ }
#endif
if ( _fd >= 0 ) {
closesocket( _fd );
@@ -497,8 +502,8 @@ namespace mongo {
void Socket::secure( SSLManager * ssl ) {
assert( ssl );
assert( _fd >= 0 );
- _ssl.reset( ssl->secure( _fd ) );
- SSL_connect( _ssl.get() );
+ _ssl = ssl->secure( _fd );
+ SSL_connect( _ssl );
}
void Socket::secureAccepted( SSLManager * ssl ) {
@@ -510,8 +515,8 @@ namespace mongo {
#ifdef MONGO_SSL
if ( _sslAccepted ) {
assert( _fd );
- _ssl.reset( _sslAccepted->secure( _fd ) );
- SSL_accept( _ssl.get() );
+ _ssl = _sslAccepted->secure( _fd );
+ SSL_accept( _ssl );
_sslAccepted = 0;
}
#endif
@@ -574,7 +579,7 @@ namespace mongo {
int Socket::_send( const char * data , int len ) {
#ifdef MONGO_SSL
if ( _ssl ) {
- return SSL_write( _ssl.get() , data , len );
+ return SSL_write( _ssl , data , len );
}
#endif
return ::send( _fd , data , len , portSendFlags );
@@ -588,7 +593,7 @@ namespace mongo {
#ifdef MONGO_SSL
if ( _ssl ) {
- log() << "SSL Error ret: " << ret << " err: " << SSL_get_error( _ssl.get() , ret )
+ log() << "SSL Error ret: " << ret << " err: " << SSL_get_error( _ssl , ret )
<< " " << ERR_error_string(ERR_get_error(), NULL)
<< endl;
}
@@ -743,7 +748,7 @@ namespace mongo {
int Socket::_recv( char *buf, int max ) {
#ifdef MONGO_SSL
if ( _ssl ){
- return SSL_read( _ssl.get() , buf , max );
+ return SSL_read( _ssl , buf , max );
}
#endif
return ::recv( _fd , buf , max , portRecvFlags );
diff --git a/util/net/sock.h b/util/net/sock.h
index 1cd51333525..f91c2881d23 100644
--- a/util/net/sock.h
+++ b/util/net/sock.h
@@ -243,7 +243,7 @@ namespace mongo {
long long _bytesOut;
#ifdef MONGO_SSL
- shared_ptr<SSL> _ssl;
+ SSL* _ssl;
SSLManager * _sslAccepted;
#endif