0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 09:06:21 +01:00

repl npe / cleanup when can't connect to master

This commit is contained in:
dwight 2008-08-17 21:32:37 -04:00
parent 8f13ff6f1a
commit 03229b8fa9
2 changed files with 8 additions and 1 deletions

View File

@ -54,7 +54,7 @@ bool DBClientConnection::connect(const char *serverAddress, string& errmsg) {
if( ip.empty() )
ip = serverAddress;
cout << "port:" << port << endl;
//cout << "port:" << port << endl;
server = auto_ptr<SockAddr>(new SockAddr(ip.c_str(), port));
if( !p.connect(*server) ) {
errmsg = string("couldn't connect to server ") + serverAddress + ' ' + ip;

View File

@ -320,6 +320,12 @@ void Source::pullOpLog() {
string ns = string("local.oplog.$") + sourceName;
auto_ptr<DBClientCursor> c =
conn->query(ns.c_str(), query.done());
if( c.get() == 0 ) {
problem() << "pull: dbclient::query returns null (conn closed?)" << endl;
resetConnection();
sleepsecs(3);
return;
}
if( !c->more() ) {
problem() << "pull: " << ns << " empty?\n";
sleepsecs(3);
@ -396,6 +402,7 @@ bool Source::sync() {
if( !conn->connect(hostName.c_str(), errmsg) ) {
resetConnection();
log() << "pull: cantconn " << errmsg << endl;
sleepsecs(1);
return false;
}
}