diff options
-rw-r--r-- | s/client.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/s/client.cpp b/s/client.cpp index 8c6983f77df..425e2a05c70 100644 --- a/s/client.cpp +++ b/s/client.cpp @@ -223,11 +223,12 @@ namespace mongo { for ( set<string>::iterator i = shards->begin(); i != shards->end(); i++ ) { string theShard = *i; bbb.append( theShard ); - ShardConnection conn( theShard , "" ); + boost::scoped_ptr<ShardConnection> conn; BSONObj res; bool ok = false; try { - ok = conn->runCommand( "admin" , options , res ); + conn.reset( new ShardConnection( theShard , "" ) ); // constructor can throw if shard is down + ok = (*conn)->runCommand( "admin" , options , res ); shardRawGLE.append( theShard , res ); } catch( std::exception &e ){ @@ -236,7 +237,7 @@ namespace mongo { // responses. warning() << "could not get last error from a shard " << theShard << causedBy( e ) << endl; - conn.done(); + conn->done(); return false; } @@ -244,7 +245,7 @@ namespace mongo { _addWriteBack( writebacks, res ); string temp = DBClientWithCommands::getLastErrorString( res ); - if ( conn->type() != ConnectionString::SYNC && ( ok == false || temp.size() ) ) { + if ( (*conn)->type() != ConnectionString::SYNC && ( ok == false || temp.size() ) ) { errors.push_back( temp ); errorObjects.push_back( res ); } @@ -257,7 +258,7 @@ namespace mongo { updatedExistingStat = -1; } - conn.done(); + conn->done(); } bbb.done(); |