summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDwight <dwight@10gen.com>2010-10-28 10:38:24 -0400
committerEliot Horowitz <eliot@10gen.com>2010-11-20 00:00:54 -0500
commit30e604c3ccd325f8ec0502fd0830bbc90df860de (patch)
treeabb02981dc249458a0292e5cc8a0ccf0280f8572
parent3d0d33f1a9545e9292ec63bf2d8ac545c7094378 (diff)
downloadmongo-30e604c3ccd325f8ec0502fd0830bbc90df860de.tar.gz
SERVER-2021 rs ScopedConn bug(2) 165 172
-rw-r--r--db/repl/health.cpp6
-rw-r--r--db/repl/rs_config.cpp22
2 files changed, 14 insertions, 14 deletions
diff --git a/db/repl/health.cpp b/db/repl/health.cpp
index 72396fe60db..c75221c5f5b 100644
--- a/db/repl/health.cpp
+++ b/db/repl/health.cpp
@@ -19,6 +19,7 @@
#include "health.h"
#include "../../util/background.h"
#include "../../client/dbclient.h"
+#include "../../client/connpool.h"
#include "../commands.h"
#include "../../util/concurrency/value.h"
#include "../../util/concurrency/task.h"
@@ -186,7 +187,7 @@ namespace mongo {
//const bo fields = BSON( "o" << false << "o2" << false );
const bo fields;
- ScopedConn conn(m->fullName());
+ ScopedDbConnection conn(m->fullName());
auto_ptr<DBClientCursor> c = conn->query(rsoplog, Query().sort("$natural",1), 20, 0, &fields);
if( c.get() == 0 ) {
@@ -245,8 +246,6 @@ namespace mongo {
ss << _table();
ss << p(time_t_to_String_short(time(0)) + " current time");
- //ss << "</pre>\n";
-
if( !otEnd.isNull() ) {
ss << "<p>Log length in time: ";
unsigned d = otEnd.getSecs() - otFirst.getSecs();
@@ -259,6 +258,7 @@ namespace mongo {
ss << "</p>\n";
}
+ conn.done();
}
void ReplSetImpl::_summarizeAsHtml(stringstream& s) const {
diff --git a/db/repl/rs_config.cpp b/db/repl/rs_config.cpp
index 61b5a8d33b2..509381ed3aa 100644
--- a/db/repl/rs_config.cpp
+++ b/db/repl/rs_config.cpp
@@ -302,9 +302,8 @@ namespace mongo {
clear();
int level = 2;
DEV level = 0;
- //log(0) << "replSet load config from: " << h.toString() << rsLog;
- auto_ptr<DBClientCursor> c;
+ BSONObj cfg;
int v = -5;
try {
if( h.isSelf() ) {
@@ -337,10 +336,12 @@ namespace mongo {
}
v = -4;
+ long long count = 0;
try {
ScopedConn conn(h.toString());
v = -3;
- c = conn->query( rsConfigNs, Query() );
+ cfg = conn->findOne(rsConfigNs, Query()).getOwned();
+ count = conn->count(rsConfigNs);
}
catch ( DBException& e) {
if ( !h.isSelf() ) {
@@ -349,13 +350,14 @@ namespace mongo {
// on startup, socket is not listening yet
DBDirectClient cli;
- c = cli.query( rsConfigNs, Query() );
+ cfg = cli.findOne( rsConfigNs, Query() ).getOwned();
+ count = cli.count(rsConfigNs);
}
+
+ if( count > 1 )
+ uasserted(13109, str::stream() << "multiple rows in " << rsConfigNs << " not supported host: " << h.toString());
- if( c.get() == 0 ) {
- version = v; return;
- }
- if( !c->more() ) {
+ if( cfg.isEmpty() ) {
version = EMPTYCONFIG;
return;
}
@@ -367,9 +369,7 @@ namespace mongo {
return;
}
- BSONObj o = c->nextSafe();
- uassert(13109, "multiple rows in " + rsConfigNs + " not supported", !c->more());
- from(o);
+ from(cfg);
checkRsConfig();
_ok = true;
log(level) << "replSet load config ok from " << (h.isSelf() ? "self" : h.toString()) << rsLog;