diff options
author | Aaron <aaron@10gen.com> | 2009-05-13 11:58:24 -0400 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2009-05-13 11:58:24 -0400 |
commit | 92aa0ce095fafc14ddb9b37e27678ccce9eb214f (patch) | |
tree | 0ba8cb03815527b54416cadbeff1e43a2fabc31f /db/curop.h | |
parent | 78b57f297ebaf75eee1f8b5060d438791a50dd87 (diff) | |
download | mongo-92aa0ce095fafc14ddb9b37e27678ccce9eb214f.tar.gz |
maintain stack of current ops, do http authentication after recording context for http output
Diffstat (limited to 'db/curop.h')
-rw-r--r-- | db/curop.h | 141 |
1 files changed, 72 insertions, 69 deletions
diff --git a/db/curop.h b/db/curop.h index 52853d119b8..2d0c86300f5 100644 --- a/db/curop.h +++ b/db/curop.h @@ -1,69 +1,72 @@ -// curop.h
-
-#pragma once
-
-#include "namespace.h"
-#include "security.h"
-
-namespace mongo {
-
- extern struct CurOp {
- void reset(time_t now) {
- active = true;
- opNum++;
- startTime = now;
- ns[0] = '?'; // just in case not set later
- *query = 0;
- killCurrentOp = 0;
- }
-
- bool active;
- unsigned opNum;
- time_t startTime;
- int op;
- char ns[Namespace::MaxNsLen+1];
- char query[128];
- char zero;
-
- CurOp() {
- opNum = 0;
- ns[sizeof(ns)-1] = 0;
- query[sizeof(query)-1] = 0;
- }
-
- 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;
- b.append("opid", opNum);
- b.append("active", active);
- if( active )
- b.append("secs_running", (int) (time(0)-startTime));
- if( op == 2004 )
- b.append("op", "query");
- else if( op == 2005 )
- b.append("op", "getMore");
- else if( op == 2001 )
- b.append("op", "update");
- else if( op == 2002 )
- b.append("op", "insert");
- else if( op == 2006 )
- b.append("op", "delete");
- else
- b.append("op", op);
- b.append("ns", ns);
- b.append("query", query);
- b.append("inLock", dbMutexInfo.isLocked());
- return b.obj();
- }
- } currentOp;
-
-}
+// curop.h + +#pragma once + +#include "namespace.h" +#include "security.h" + +namespace mongo { + + struct CurOp { + void reset(time_t now) { + active = true; + opNum++; + startTime = now; + ns[0] = '?'; // just in case not set later + *query = 0; + killCurrentOp = 0; + } + + bool active; + unsigned opNum; + time_t startTime; + int op; + char ns[Namespace::MaxNsLen+1]; + char query[128]; + char zero; + + CurOp() { + opNum = 0; + ns[sizeof(ns)-1] = 0; + query[sizeof(query)-1] = 0; + } + + 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() const { + BSONObjBuilder b; + b.append("opid", opNum); + b.append("active", active); + if( active ) + b.append("secs_running", (int) (time(0)-startTime)); + if( op == 2004 ) + b.append("op", "query"); + else if( op == 2005 ) + b.append("op", "getMore"); + else if( op == 2001 ) + b.append("op", "update"); + else if( op == 2002 ) + b.append("op", "insert"); + else if( op == 2006 ) + b.append("op", "delete"); + else + b.append("op", op); + b.append("ns", ns); + b.append("query", query); + b.append("inLock", dbMutexInfo.isLocked()); + return b.obj(); + } + }; + + CurOp ¤tOp(); + void pushCurrentOp(); + void popCurrentOp(); +} |