summaryrefslogtreecommitdiff
path: root/client/dbclient.cpp
diff options
context:
space:
mode:
authorAntonin Kral <a.kral@bobek.cz>2011-12-15 09:35:47 +0100
committerAntonin Kral <a.kral@bobek.cz>2011-12-15 09:35:47 +0100
commitf0d9a01bccdaeb466c12c92057914bbfef59526c (patch)
tree7679efa1f0daf7d1d906882a15dc77af6b7aef32 /client/dbclient.cpp
parent5d342a758c6095b4d30aba0750b54f13b8916f51 (diff)
downloadmongodb-f0d9a01bccdaeb466c12c92057914bbfef59526c.tar.gz
Imported Upstream version 2.0.2
Diffstat (limited to 'client/dbclient.cpp')
-rw-r--r--client/dbclient.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/client/dbclient.cpp b/client/dbclient.cpp
index dadf7e4..5faeccf 100644
--- a/client/dbclient.cpp
+++ b/client/dbclient.cpp
@@ -247,6 +247,11 @@ namespace mongo {
return o["ok"].trueValue();
}
+ bool DBClientWithCommands::isNotMasterErrorString( const BSONElement& e ) {
+ return e.type() == String && str::contains( e.valuestr() , "not master" );
+ }
+
+
enum QueryOptions DBClientWithCommands::availableOptions() {
if ( !_haveCachedAvailableOptions ) {
BSONObj ret;
@@ -599,6 +604,19 @@ namespace mongo {
return true;
}
+
+ inline bool DBClientConnection::runCommand(const string &dbname, const BSONObj& cmd, BSONObj &info, int options) {
+ if ( DBClientWithCommands::runCommand( dbname , cmd , info , options ) )
+ return true;
+
+ if ( clientSet && isNotMasterErrorString( info["errmsg"] ) ) {
+ clientSet->isntMaster();
+ }
+
+ return false;
+ }
+
+
void DBClientConnection::_checkConnection() {
if ( !_failed )
return;
@@ -982,8 +1000,7 @@ namespace mongo {
if ( clientSet && nReturned ) {
assert(data);
BSONObj o(data);
- BSONElement e = getErrField(o);
- if ( e.type() == String && str::contains( e.valuestr() , "not master" ) ) {
+ if ( isNotMasterErrorString( getErrField(o) ) ) {
clientSet->isntMaster();
}
}