diff --git a/db/dbcommands.cpp b/db/dbcommands.cpp index 58a08567f1c..d60d57490d0 100644 --- a/db/dbcommands.cpp +++ b/db/dbcommands.cpp @@ -370,7 +370,7 @@ namespace mongo { if ( anyReplEnabled() ){ BSONObjBuilder bb( result.subobjStart( "repl" ) ); - appendReplicationInfo( bb , authed ); + appendReplicationInfo( bb , authed , cmdObj["repl"].numberInt() ); bb.done(); } diff --git a/db/repl.cpp b/db/repl.cpp index c0721c93d11..27056645162 100644 --- a/db/repl.cpp +++ b/db/repl.cpp @@ -258,7 +258,7 @@ namespace mongo { return replPair || replSettings.slave || replSettings.master; } - void appendReplicationInfo( BSONObjBuilder& result , bool authed ){ + void appendReplicationInfo( BSONObjBuilder& result , bool authed , int level ){ if ( replAllDead ) { result.append("ismaster", 0.0); @@ -281,6 +281,20 @@ namespace mongo { result.append("msg", "not paired"); } + if ( level ){ + BSONObjBuilder sources( result.subarrayStart( "sources" ) ); + + readlock lk( "local.sources" ); + Client::Context ctx( "local.sources" ); + auto_ptr c = findTableScan("local.sources", BSONObj()); + int n = 0; + while ( c->ok() ){ + sources.append( BSONObjBuilder::numStr( n++ ) , c->current() ); + c->advance(); + } + + sources.done(); + } } class CmdIsMaster : public Command { @@ -1597,11 +1611,10 @@ namespace mongo { void replSlaveThread() { sleepsecs(1); - + Client::initThread("replslave"); + { dblock lk; - - Client::initThread("replslave"); cc().getAuthenticationInfo()->authorize("admin"); BSONObj obj; diff --git a/db/repl.h b/db/repl.h index e656388455d..4a8caba29fe 100644 --- a/db/repl.h +++ b/db/repl.h @@ -326,6 +326,6 @@ namespace mongo { }; bool anyReplEnabled(); - void appendReplicationInfo( BSONObjBuilder& result , bool authed ); + void appendReplicationInfo( BSONObjBuilder& result , bool authed , int level = 0 ); } // namespace mongo