diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2017-09-06 10:28:31 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2017-09-06 15:40:53 -0400 |
commit | e00c6d29996ba52b5a77a072d1c5c555f62b8534 (patch) | |
tree | 8301d5067bc8e69fd62f9a97ce87d732fa998767 /src/mongo/db/session_catalog.cpp | |
parent | 673d970768ec8c2b065ce0b982e91fadf21e7e20 (diff) | |
download | mongo-e00c6d29996ba52b5a77a072d1c5c555f62b8534.tar.gz |
SERVER-30936 Ensure operation session info is initialized only once
Diffstat (limited to 'src/mongo/db/session_catalog.cpp')
-rw-r--r-- | src/mongo/db/session_catalog.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/mongo/db/session_catalog.cpp b/src/mongo/db/session_catalog.cpp index 4e0a28bb0ac..58034c327ba 100644 --- a/src/mongo/db/session_catalog.cpp +++ b/src/mongo/db/session_catalog.cpp @@ -137,13 +137,15 @@ ScopedCheckedOutSession SessionCatalog::checkOutSession(OperationContext* opCtx) invariant(!opCtx->lockState()->isLocked()); invariant(opCtx->getLogicalSessionId()); + const auto& lsid = *opCtx->getLogicalSessionId(); + stdx::unique_lock<stdx::mutex> ul(_mutex); - auto sri = _getOrCreateSessionRuntimeInfo_inlock(opCtx, *opCtx->getLogicalSessionId(), ul); + auto sri = _getOrCreateSessionRuntimeInfo(opCtx, lsid, ul); // Wait until the session is no longer in use opCtx->waitForConditionOrInterrupt( - sri->availableCondVar, ul, [sri]() { return sri->state != SessionRuntimeInfo::kInUse; }); + sri->availableCondVar, ul, [&sri]() { return sri->state != SessionRuntimeInfo::kInUse; }); invariant(sri->state == SessionRuntimeInfo::kAvailable); sri->state = SessionRuntimeInfo::kInUse; @@ -155,7 +157,7 @@ ScopedSession SessionCatalog::getOrCreateSession(OperationContext* opCtx, const LogicalSessionId& lsid) { stdx::unique_lock<stdx::mutex> ul(_mutex); - return ScopedSession(_getOrCreateSessionRuntimeInfo_inlock(opCtx, lsid, ul)); + return ScopedSession(_getOrCreateSessionRuntimeInfo(opCtx, lsid, ul)); } void SessionCatalog::resetSessions() { @@ -165,10 +167,8 @@ void SessionCatalog::resetSessions() { } } -std::shared_ptr<SessionCatalog::SessionRuntimeInfo> -SessionCatalog::_getOrCreateSessionRuntimeInfo_inlock(OperationContext* opCtx, - const LogicalSessionId& lsid, - stdx::unique_lock<stdx::mutex>& ul) { +std::shared_ptr<SessionCatalog::SessionRuntimeInfo> SessionCatalog::_getOrCreateSessionRuntimeInfo( + OperationContext* opCtx, const LogicalSessionId& lsid, stdx::unique_lock<stdx::mutex>& ul) { invariant(!opCtx->lockState()->inAWriteUnitOfWork()); auto it = _txnTable.find(lsid); |