diff options
author | Esha Maharishi <esha.maharishi@mongodb.com> | 2016-12-13 11:07:14 -0500 |
---|---|---|
committer | Esha Maharishi <esha.maharishi@mongodb.com> | 2016-12-13 11:07:14 -0500 |
commit | 4061adae4c4cc556954ae50924f4aadd9f8ac732 (patch) | |
tree | 90e8bd1fcd75afd36f4f4d31d9344a3917e6b44c /src/mongo/db/operation_context_impl.cpp | |
parent | 7678cba70d790eab3eb546988c77bb34ab83da1a (diff) | |
download | mongo-4061adae4c4cc556954ae50924f4aadd9f8ac732.tar.gz |
Revert "SERVER-26126 Remove broken LockState caching"
This reverts commit 6dc9fc6ba93b62830dd905f6fac39e0802566a9a.
Diffstat (limited to 'src/mongo/db/operation_context_impl.cpp')
-rw-r--r-- | src/mongo/db/operation_context_impl.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/mongo/db/operation_context_impl.cpp b/src/mongo/db/operation_context_impl.cpp index 0ccdbbbfbef..7fae6cfa4a7 100644 --- a/src/mongo/db/operation_context_impl.cpp +++ b/src/mongo/db/operation_context_impl.cpp @@ -47,17 +47,38 @@ std::unique_ptr<Locker> newLocker() { return stdx::make_unique<MMAPV1LockerImpl>(); return stdx::make_unique<DefaultLockerImpl>(); } + +class ClientOperationInfo { +public: + std::unique_ptr<Locker>& locker() { + if (!_locker) { + _locker = newLocker(); + } + return _locker; + } + +private: + std::unique_ptr<Locker> _locker; +}; + +const auto clientOperationInfoDecoration = Client::declareDecoration<ClientOperationInfo>(); + } // namespace using std::string; OperationContextImpl::OperationContextImpl(Client* client, unsigned opId) : OperationContext(client, opId) { - setLockState(newLocker()); + setLockState(std::move(clientOperationInfoDecoration(client).locker())); StorageEngine* storageEngine = getServiceContext()->getGlobalStorageEngine(); setRecoveryUnit(storageEngine->newRecoveryUnit(), kNotInUnitOfWork); } +OperationContextImpl::~OperationContextImpl() { + lockState()->assertEmptyAndReset(); + clientOperationInfoDecoration(getClient()).locker() = releaseLockState(); +} + ProgressMeter* OperationContextImpl::setMessage_inlock(const char* msg, const std::string& name, unsigned long long progressMeterTotal, |