diff --git a/db/db.cpp b/db/db.cpp index bcba698b22e..b03651ef5b9 100644 --- a/db/db.cpp +++ b/db/db.cpp @@ -457,6 +457,8 @@ sendmore: } } + void flushDiagLog(); + /** * does background async flushes of mmapped files */ @@ -472,6 +474,7 @@ sendmore: log(1) << "--syncdelay " << _sleepsecs << endl; int time_flushing = 0; while ( ! inShutdown() ){ + flushDiagLog(); if ( _sleepsecs == 0 ){ // in case at some point we add an option to change at runtime sleepsecs(5); diff --git a/db/dbcommands.cpp b/db/dbcommands.cpp index 4e4ab9c3b70..3930161bc52 100644 --- a/db/dbcommands.cpp +++ b/db/dbcommands.cpp @@ -44,7 +44,7 @@ namespace mongo { extern int otherTraceLevel; - void flushOpLog( stringstream &ss ); + void flushDiagLog(); /* reset any errors so that getlasterror comes back clean. @@ -460,9 +460,7 @@ namespace mongo { virtual LockType locktype() const { return WRITE; } bool run(const string& dbname , BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool) { int was = _diaglog.setLevel( cmdObj.firstElement().numberInt() ); - stringstream ss; - flushOpLog( ss ); - out() << ss.str() << endl; + flushDiagLog(); if ( !cmdLine.quiet ) tlog() << "CMD: diagLogging set to " << _diaglog.level << " from: " << was << endl; result.append( "was" , was ); diff --git a/db/instance.cpp b/db/instance.cpp index ad544bd04ad..1031c7f0c7b 100644 --- a/db/instance.cpp +++ b/db/instance.cpp @@ -62,9 +62,9 @@ namespace mongo { bool useCursors = true; bool useHints = true; - void flushOpLog( stringstream &ss ) { + void flushDiagLog() { if( _diaglog.f && _diaglog.f->is_open() ) { - ss << "flushing op log and files\n"; + log() << "flushing diag log" << endl; _diaglog.flush(); } } @@ -745,9 +745,7 @@ namespace mongo { ListeningSockets::get()->closeAll(); log() << "shutdown: going to flush oplog..." << endl; - stringstream ss2; - flushOpLog( ss2 ); - rawOut( ss2.str() ); + flushDiagLog(); /* must do this before unmapping mem or you may get a seg fault */ log() << "shutdown: going to close sockets..." << endl;