diff options
author | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2020-11-30 23:09:38 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-12-01 18:49:02 +0000 |
commit | a2486fc9d08029b28f7341d1ed040c3d65d7214d (patch) | |
tree | 4321ff88b93429505a53520f780443f049fff814 /src/mongo/db/curop.cpp | |
parent | 25146a681ed8b646162608c218814b7f183bd89a (diff) | |
download | mongo-a2486fc9d08029b28f7341d1ed040c3d65d7214d.tar.gz |
SERVER-53137 The CurOp constructor should initialize its variables prior to being added to the stack of active CurOp objects
Diffstat (limited to 'src/mongo/db/curop.cpp')
-rw-r--r-- | src/mongo/db/curop.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/mongo/db/curop.cpp b/src/mongo/db/curop.cpp index 4d03867b805..f23c04e8280 100644 --- a/src/mongo/db/curop.cpp +++ b/src/mongo/db/curop.cpp @@ -343,14 +343,8 @@ void CurOp::setGenericCursor_inlock(GenericCursor gc) { _genericCursor = std::move(gc); } -CurOp::CurOp(OperationContext* opCtx) : CurOp(opCtx, &_curopStack(opCtx)) { - // If this is a sub-operation, we store the snapshot of lock stats as the base lock stats of the - // current operation. - if (_parent != nullptr) - _lockStatsBase = opCtx->lockState()->getLockerInfo(boost::none)->stats; -} - -CurOp::CurOp(OperationContext* opCtx, CurOpStack* stack) : _stack(stack) { +void CurOp::_finishInit(OperationContext* opCtx, CurOpStack* stack) { + _stack = stack; _tickSource = SystemTickSource::get(); if (opCtx) { @@ -360,6 +354,20 @@ CurOp::CurOp(OperationContext* opCtx, CurOpStack* stack) : _stack(stack) { } } +CurOp::CurOp(OperationContext* opCtx) { + // If this is a sub-operation, we store the snapshot of lock stats as the base lock stats of the + // current operation. + if (_parent != nullptr) + _lockStatsBase = opCtx->lockState()->getLockerInfo(boost::none)->stats; + + // Add the CurOp object onto the stack of active CurOp objects. + _finishInit(opCtx, &_curopStack(opCtx)); +} + +CurOp::CurOp(OperationContext* opCtx, CurOpStack* stack) { + _finishInit(opCtx, stack); +} + CurOp::~CurOp() { if (parent() != nullptr) parent()->yielded(_numYields.load()); |