mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-30 00:56:44 +01:00
fix MessagingPort leaking SERVER-777
From: Guillaume Delannoy <guillaumedelannoy@ymail.com> Signed-off-by: Eliot Horowitz <eliot@10gen.com>
This commit is contained in:
parent
1ffe1df423
commit
df6709a2da
24
db/db.cpp
24
db/db.cpp
@ -191,22 +191,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;
|
||||
}
|
||||
|
||||
@ -218,11 +218,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);
|
||||
@ -233,17 +233,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 );
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user