diff --git a/db/curop.h b/db/curop.h index e3b35619155..52853d119b8 100644 --- a/db/curop.h +++ b/db/curop.h @@ -32,13 +32,17 @@ namespace mongo { } BSONObj info() { + AuthenticationInfo *ai = authInfo.get(); + if( ai == 0 || !ai->isAuthorized("admin") ) { + BSONObjBuilder b; + b.append("err", "unauthorized"); + return b.obj(); + } + return infoNoauth(); + } + + BSONObj infoNoauth() { BSONObjBuilder b; - AuthenticationInfo *ai = authInfo.get(); - if( ai == 0 || !ai->isAuthorized("admin") ) { - b.append("err", "unauthorized"); - return b.obj(); - } - b.append("opid", opNum); b.append("active", active); if( active ) diff --git a/db/db.cpp b/db/db.cpp index 6dc705bd67b..2e4aee1abc4 100644 --- a/db/db.cpp +++ b/db/db.cpp @@ -603,6 +603,9 @@ namespace mongo { } void abruptQuit(int x) { + ostringstream ossOp; + ossOp << "Last op: " << currentOp.infoNoauth() << endl; + rawOut( ossOp.str() ); ostringstream oss; oss << "Got signal: " << x << ", printing backtrace:" << endl; printStackTrace( oss ); diff --git a/db/instance.cpp b/db/instance.cpp index 1383a80733c..7d3b8de6949 100644 --- a/db/instance.cpp +++ b/db/instance.cpp @@ -26,7 +26,6 @@ #include "instance.h" #include "lasterror.h" #include "security.h" -#include "curop.h" #include "json.h" #include "reccache.h" @@ -614,7 +613,7 @@ namespace mongo { stringstream ss; ss << "dbexit: " << why << endl; rawOut( ss.str() ); - + stringstream ss2; flushOpLog( ss2 ); rawOut( ss2.str() ); diff --git a/db/instance.h b/db/instance.h index d8c441186ff..925cdb49ac3 100644 --- a/db/instance.h +++ b/db/instance.h @@ -20,10 +20,13 @@ #pragma once #include "../client/dbclient.h" +#include "curop.h" #include "security.h" namespace mongo { + extern CurOp currentOp; + // turn on or off the oplog.* files which the db can generate. // these files are for diagnostic purposes and are unrelated to // local.oplog.$main used by replication.