summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgreg <greg@ubuntu.(none)>2011-03-02 10:31:40 -0500
committerEliot Horowitz <eliot@10gen.com>2011-03-31 03:12:40 -0400
commit7c5b035e1bad0a4f1d84adde04df49b57dae7828 (patch)
tree7b3472d14c40f744f213d24f8a6a81c96d413a5b
parent5cc6b7bca4a62674b51c1446181d4e652fc94700 (diff)
downloadmongo-7c5b035e1bad0a4f1d84adde04df49b57dae7828.tar.gz
Cleanup connection when getlasterror fails
-rw-r--r--s/client.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/s/client.cpp b/s/client.cpp
index b8559b692c4..1289b79b46f 100644
--- a/s/client.cpp
+++ b/s/client.cpp
@@ -177,7 +177,21 @@ namespace mongo {
ShardConnection conn( theShard , "" );
BSONObj res;
- bool ok = conn->runCommand( "admin" , options , res );
+ bool ok = false;
+ try{
+ ok = conn->runCommand( "admin" , options , res );
+ }
+ catch( std::exception &e ){
+
+ warning() << "Could not get last error." << m_error_message( e.what() ) << endl;
+
+ // Catch everything that happens here, since we need to ensure we return our connection when we're
+ // finished.
+ conn.done();
+
+ return false;
+ }
+
res = res.getOwned();
conn.done();
@@ -228,7 +242,21 @@ namespace mongo {
bbb.append( theShard );
ShardConnection conn( theShard , "" );
BSONObj res;
- bool ok = conn->runCommand( "admin" , options , res );
+ bool ok = false;
+ try{
+ ok = conn->runCommand( "admin" , options , res );
+ }
+ catch( std::exception &e ){
+
+ // Safe to return here, since we haven't started any extra processing yet, just collecting
+ // responses.
+
+ warning() << "Could not get last error." << m_error_message( e.what() ) << endl;
+ conn.done();
+
+ return false;
+ }
+
_addWriteBack( writebacks, res );
string temp = DBClientWithCommands::getLastErrorString( res );