summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2011-03-30 13:49:19 -0400
committerEliot Horowitz <eliot@10gen.com>2011-03-31 03:08:59 -0400
commit444950f086c004324905f4ecac58b1a120384197 (patch)
treef55b23111b931cbe134f43729bf6a16361022fd3
parent62cbfb842cf627946ca99e68a8090df1a65de2c5 (diff)
downloadmongo-444950f086c004324905f4ecac58b1a120384197.tar.gz
safer not master check
-rw-r--r--client/dbclient.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/client/dbclient.cpp b/client/dbclient.cpp
index b4214abbbb2..a68b1af2adc 100644
--- a/client/dbclient.cpp
+++ b/client/dbclient.cpp
@@ -915,13 +915,14 @@ namespace mongo {
void DBClientConnection::checkResponse( const char *data, int nReturned ) {
/* check for errors. the only one we really care about at
- this stage is "not master" */
+ * this stage is "not master"
+ */
+
if ( clientSet && nReturned ) {
assert(data);
BSONObj o(data);
- BSONElement e = o.firstElement();
- if ( strcmp(e.fieldName(), "$err") == 0 &&
- e.type() == String && strncmp(e.valuestr(), "not master", 10) == 0 ) {
+ BSONElement e = o["$err"];
+ if ( e.type() == String && str::contains( e.valuestr() , "not master" ) ) {
clientSet->isntMaster();
}
}