summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2010-03-29 10:11:16 -0400
committerEliot Horowitz <eliot@10gen.com>2010-06-25 12:13:28 -0400
commit48b6a237d21a3a634694d823a1acdb0c6302474e (patch)
treed17878566e6eb523991c9dded4b5259c2c3cf40e
parent8cffdd6ed0e8e1c37b565e86b371c52e0190c706 (diff)
downloadmongo-48b6a237d21a3a634694d823a1acdb0c6302474e.tar.gz
fix MessagingPort leaking SERVER-777
From: Guillaume Delannoy <guillaumedelannoy@ymail.com> Signed-off-by: Eliot Horowitz <eliot@10gen.com>
-rw-r--r--db/db.cpp24
-rw-r--r--util/message_server_port.cpp5
2 files changed, 14 insertions, 15 deletions
diff --git a/db/db.cpp b/db/db.cpp
index 51369bbb5e9..9be403129a3 100644
--- a/db/db.cpp
+++ b/db/db.cpp
@@ -193,22 +193,22 @@ namespace mongo {
LastError *le = new LastError();
lastError.reset(le);
- MessagingPort& dbMsgPort = *connGrab;
+ auto_ptr<MessagingPort> dbMsgPort( connGrab );
connGrab = 0;
Client& c = cc();
try {
- c.getAuthenticationInfo()->isLocalHost = dbMsgPort.farEnd.isLocalHost();
+ c.getAuthenticationInfo()->isLocalHost = dbMsgPort->farEnd.isLocalHost();
Message m;
while ( 1 ) {
m.reset();
- if ( !dbMsgPort.recv(m) ) {
+ if ( !dbMsgPort->recv(m) ) {
if( !cmdLine.quiet )
- log() << "end connection " << dbMsgPort.farEnd.toString() << endl;
- dbMsgPort.shutdown();
+ log() << "end connection " << dbMsgPort->farEnd.toString() << endl;
+ dbMsgPort->shutdown();
break;
}
@@ -220,11 +220,11 @@ namespace mongo {
lastError.startRequest( m , le );
DbResponse dbresponse;
- if ( !assembleResponse( m, dbresponse, dbMsgPort.farEnd.sa ) ) {
- out() << curTimeMillis() % 10000 << " end msg " << dbMsgPort.farEnd.toString() << endl;
+ if ( !assembleResponse( m, dbresponse, dbMsgPort->farEnd.sa ) ) {
+ out() << curTimeMillis() % 10000 << " end msg " << dbMsgPort->farEnd.toString() << endl;
/* todo: we may not wish to allow this, even on localhost: very low priv accounts could stop us. */
- if ( dbMsgPort.farEnd.isLocalHost() ) {
- dbMsgPort.shutdown();
+ if ( dbMsgPort->farEnd.isLocalHost() ) {
+ dbMsgPort->shutdown();
sleepmillis(50);
problem() << "exiting end msg" << endl;
dbexit(EXIT_CLEAN);
@@ -235,17 +235,17 @@ namespace mongo {
}
if ( dbresponse.response )
- dbMsgPort.reply(m, *dbresponse.response, dbresponse.responseTo);
+ dbMsgPort->reply(m, *dbresponse.response, dbresponse.responseTo);
}
}
catch ( AssertionException& ) {
problem() << "AssertionException in connThread, closing client connection" << endl;
- dbMsgPort.shutdown();
+ dbMsgPort->shutdown();
}
catch ( SocketException& ) {
problem() << "SocketException in connThread, closing client connection" << endl;
- dbMsgPort.shutdown();
+ dbMsgPort->shutdown();
}
catch ( const ClockSkewException & ) {
exitCleanly( EXIT_CLOCK_SKEW );
diff --git a/util/message_server_port.cpp b/util/message_server_port.cpp
index fa8f9e5e8d5..2350ec2d665 100644
--- a/util/message_server_port.cpp
+++ b/util/message_server_port.cpp
@@ -31,7 +31,7 @@ namespace mongo {
void threadRun(){
assert( grab );
- MessagingPort * p = grab;
+ auto_ptr<MessagingPort> p( grab );
grab = 0;
Message m;
@@ -45,12 +45,11 @@ namespace mongo {
break;
}
- handler->process( m , p );
+ handler->process( m , p.get() );
}
}
catch ( ... ){
problem() << "uncaught exception in PortMessageServer::threadRun, closing connection" << endl;
- delete p;
}
}