summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorAntonin Kral <a.kral@bobek.cz>2012-06-05 19:50:36 +0200
committerAntonin Kral <a.kral@bobek.cz>2012-06-05 19:50:36 +0200
commit291c9687fb2307dc22d1f269eb4d0aa98fe8cadc (patch)
treef46fac7bf8530d100aa55da89dfaa53490fbb350 /client
parent6d0f215499dda50fdba4a6f60ab359efe0054e0d (diff)
parent3703a282eca7e79e91f4bd651b1b861b76dc6c68 (diff)
downloadmongodb-291c9687fb2307dc22d1f269eb4d0aa98fe8cadc.tar.gz
Merge tag 'upstream/2.0.6'
Upstream version 2.0.6
Diffstat (limited to 'client')
-rw-r--r--client/dbclient_rs.cpp27
-rw-r--r--client/dbclient_rs.h5
2 files changed, 24 insertions, 8 deletions
diff --git a/client/dbclient_rs.cpp b/client/dbclient_rs.cpp
index 4a8112b..c792656 100644
--- a/client/dbclient_rs.cpp
+++ b/client/dbclient_rs.cpp
@@ -303,12 +303,29 @@ namespace mongo {
}
}
- void ReplicaSetMonitor::_checkStatus(DBClientConnection *conn) {
+ void ReplicaSetMonitor::_checkStatus( const string& hostAddr ) {
BSONObj status;
- if (!conn->runCommand("admin", BSON("replSetGetStatus" << 1), status) ||
- !status.hasField("members") ||
- status["members"].type() != Array) {
+ /* replSetGetStatus requires admin auth so use a connection from the pool,
+ * which are authenticated with the keyFile credentials.
+ */
+ ScopedDbConnection authenticatedConn( hostAddr );
+
+ if ( !authenticatedConn->runCommand( "admin", BSON( "replSetGetStatus" << 1 ), status )) {
+ LOG(1) << "dbclient_rs replSetGetStatus failed" << endl;
+ authenticatedConn.done(); // connection worked properly, but we got an error from server
+ return;
+ }
+
+ // Make sure we return when finished
+ authenticatedConn.done();
+
+ if( !status.hasField("members") ) {
+ log() << "dbclient_rs error expected members field in replSetGetStatus result" << endl;
+ return;
+ }
+ if( status["members"].type() != Array) {
+ log() << "dbclient_rs error expected members field in replSetGetStatus result to be an array" << endl;
return;
}
@@ -523,7 +540,7 @@ namespace mongo {
}
_checkHosts( b.arr(), changed);
- _checkStatus( conn );
+ _checkStatus( conn->getServerAddress() );
}
catch ( std::exception& e ) {
diff --git a/client/dbclient_rs.h b/client/dbclient_rs.h
index bf91f09..318b3cf 100644
--- a/client/dbclient_rs.h
+++ b/client/dbclient_rs.h
@@ -120,7 +120,7 @@ namespace mongo {
* Use replSetGetStatus command to make sure hosts in host list are up
* and readable. Sets Node::ok appropriately.
*/
- void _checkStatus(DBClientConnection *conn);
+ void _checkStatus( const string& hostAddr );
/**
* Add array of hosts to host list. Doesn't do anything if hosts are
@@ -181,9 +181,8 @@ namespace mongo {
string _name;
struct Node {
Node( const HostAndPort& a , DBClientConnection* c )
- : addr( a ) , conn(c) , ok(true) ,
+ : addr( a ) , conn(c) , ok( c != NULL ),
ismaster(false), secondary( false ) , hidden( false ) , pingTimeMillis(0) {
- ok = conn.get() == NULL;
}
bool okForSecondaryQueries() const {