diff --git a/shell/utils.cpp b/shell/utils.cpp index e7db1ed7d2c..1fd3ef02a53 100644 --- a/shell/utils.cpp +++ b/shell/utils.cpp @@ -271,10 +271,13 @@ namespace mongo { cerr << "count for port: " << port_ << " is not 0 is: " << dbs.count( port_ ) << endl; assert( dbs.count( port_ ) == 0 ); } - if ( port_ <= 0 || portToSocket.find( port_ ) == portToSocket.end() || portToSocket[ port_ ] <= 0 ) { + if ( port_ > 0 ) { + if ( portToSocket.find( port_ ) == portToSocket.end() ) { oldSocket_ = -1; - } else { - oldSocket_ = portToSocket[ port_ ]; + } else { + oldSocket_ = portToSocket[ port_ ]; + assert( oldSocket_ > 0 ); + } } } @@ -284,11 +287,8 @@ namespace mongo { // port allocator left this socket open to prevent someone else from grabbing // the port -- now we need to close the socket - if ( oldSocket_ > 0 ) { + if ( oldSocket_ > 0 ) assert( 0 == close( oldSocket_ ) ); - portToSocket[ port_ ] = -1; - oldSocket_ = -1; - } fflush( 0 ); pid_ = fork();