summaryrefslogtreecommitdiff
path: root/src/mongo/db/curop.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/curop.cpp')
-rw-r--r--src/mongo/db/curop.cpp77
1 files changed, 24 insertions, 53 deletions
diff --git a/src/mongo/db/curop.cpp b/src/mongo/db/curop.cpp
index 640c82063e0..4c41b5bd365 100644
--- a/src/mongo/db/curop.cpp
+++ b/src/mongo/db/curop.cpp
@@ -56,10 +56,10 @@ namespace mongo {
*
* The stack itself is represented in the _parent pointers of the CurOp class.
*/
- class CurOp::ClientCuropStack {
- MONGO_DISALLOW_COPYING(ClientCuropStack);
+ class CurOp::CurOpStack {
+ MONGO_DISALLOW_COPYING(CurOpStack);
public:
- ClientCuropStack() : _base(nullptr, this) {}
+ CurOpStack() : _base(nullptr, this) {}
/**
* Returns the top of the CurOp stack.
@@ -69,15 +69,15 @@ namespace mongo {
/**
* Adds "curOp" to the top of the CurOp stack for a client. Called by CurOp's constructor.
*/
- void push(Client* client, CurOp* curOp) {
- invariant(client);
- if (_client) {
- invariant(_client == client);
+ void push(OperationContext* opCtx, CurOp* curOp) {
+ invariant(opCtx);
+ if (_opCtx) {
+ invariant(_opCtx == opCtx);
}
else {
- _client = client;
+ _opCtx = opCtx;
}
- boost::lock_guard<Client> lk(*_client);
+ boost::lock_guard<Client> lk(*_opCtx->getClient());
push_nolock(curOp);
}
@@ -101,20 +101,20 @@ namespace mongo {
// the client during the final pop.
const bool shouldLock = _top->_parent;
if (shouldLock) {
- invariant(_client);
- _client->lock();
+ invariant(_opCtx);
+ _opCtx->getClient()->lock();
}
invariant(_top);
CurOp* retval = _top;
_top = _top->_parent;
if (shouldLock) {
- _client->unlock();
+ _opCtx->getClient()->unlock();
}
return retval;
}
private:
- Client* _client = nullptr;
+ OperationContext* _opCtx = nullptr;
// Top of the stack of CurOps for a Client.
CurOp* _top = nullptr;
@@ -123,8 +123,8 @@ namespace mongo {
const CurOp _base;
};
- const Client::Decoration<CurOp::ClientCuropStack> CurOp::_curopStack =
- Client::declareDecoration<CurOp::ClientCuropStack>();
+ const OperationContext::Decoration<CurOp::CurOpStack> CurOp::_curopStack =
+ OperationContext::declareDecoration<CurOp::CurOpStack>();
// Enabling the maxTimeAlwaysTimeOut fail point will cause any query or command run with a
// valid non-zero max time to fail immediately. Any getmore operation on a cursor already
@@ -146,33 +146,18 @@ namespace mongo {
CurOp* CurOp::get(const OperationContext* opCtx) { return get(*opCtx); }
- CurOp* CurOp::get(const OperationContext& opCtx) {
- return _curopStack(opCtx.getClient()).top();
- }
+ CurOp* CurOp::get(const OperationContext& opCtx) { return _curopStack(opCtx).top(); }
- CurOp::CurOp(Client* client) : CurOp(client, &_curopStack(client)) {}
+ CurOp::CurOp(OperationContext* opCtx) : CurOp(opCtx, &_curopStack(opCtx)) {}
- CurOp::CurOp(Client* client, ClientCuropStack* stack) : _stack(stack) {
- if (client) {
- _stack->push(client, this);
+ CurOp::CurOp(OperationContext* opCtx, CurOpStack* stack) : _stack(stack) {
+ if (opCtx) {
+ _stack->push(opCtx, this);
}
else {
_stack->push_nolock(this);
}
_start = 0;
- _active = false;
- _reset();
- _op = 0;
- _opNum = _nextOpNum.fetchAndAdd(1);
- _command = NULL;
- }
-
- CurOp::CurOp(Client* client, int op) : CurOp(client, &_curopStack(client)) {
- _op = op;
- _active = true;
- }
-
- void CurOp::_reset() {
_isCommand = false;
_dbprofile = 0;
_end = 0;
@@ -183,20 +168,11 @@ namespace mongo {
_killPending.store(0);
_numYields = 0;
_expectedLatencyMs = 0;
+ _op = 0;
+ _command = NULL;
}
- void CurOp::reset() {
- _reset();
- _start = 0;
- _opNum = _nextOpNum.fetchAndAdd(1);
- _ns = "";
- _debug.reset();
- _query.reset();
- _active = true; // this should be last for ui clarity
- }
-
- void CurOp::reset(int op) {
- reset();
+ void CurOp::setOp(int op) {
_op = op;
}
@@ -254,11 +230,8 @@ namespace mongo {
}
void CurOp::reportState(BSONObjBuilder* builder) {
- builder->append("opid", _opNum);
- bool a = _active && _start;
- builder->append("active", a);
- if( a ) {
+ if (_start) {
builder->append("secs_running", elapsedSeconds() );
builder->append("microsecs_running", static_cast<long long int>(elapsedMicros()) );
}
@@ -412,8 +385,6 @@ namespace mongo {
}
- AtomicUInt32 CurOp::_nextOpNum;
-
static Counter64 returnedCounter;
static Counter64 insertedCounter;
static Counter64 updatedCounter;