diff options
author | Eric Milkie <milkie@10gen.com> | 2012-01-17 17:31:32 -0500 |
---|---|---|
committer | Eric Milkie <milkie@10gen.com> | 2012-01-24 09:18:05 -0500 |
commit | c202889e9c3d50f3e7557ceb2b1e505b519a7955 (patch) | |
tree | b9aede52471e85ff1ea0a691e7261298f08d0fb8 | |
parent | 078c791acd376d60c770c444b3fcd2f5a006baa1 (diff) | |
download | mongo-c202889e9c3d50f3e7557ceb2b1e505b519a7955.tar.gz |
SERVER-3763 SERVER-4643 catch exceptions on connect to other shards when handling multiple shard case
-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(); |