summaryrefslogtreecommitdiff
path: root/src/mongo/db/session_catalog.cpp
diff options
context:
space:
mode:
authorjinichu <jinnybyun@gmail.com>2018-07-05 15:39:07 -0400
committerjinichu <jinnybyun@gmail.com>2018-07-05 15:39:07 -0400
commit1447252f5f44e4a2df4b7e38d4bdef0d88e526c4 (patch)
tree20e6c04726ab6e63130c669a7f6bb60040123d3f /src/mongo/db/session_catalog.cpp
parentc0fecea1c3eb40fe6b5affe7cd505b5ce7dc2faa (diff)
downloadmongo-1447252f5f44e4a2df4b7e38d4bdef0d88e526c4.tar.gz
SERVER-35173 Added autocommit value to currentOp's transaction sub-document
Diffstat (limited to 'src/mongo/db/session_catalog.cpp')
-rw-r--r--src/mongo/db/session_catalog.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/mongo/db/session_catalog.cpp b/src/mongo/db/session_catalog.cpp
index 6dd27f2f501..62f01f567a1 100644
--- a/src/mongo/db/session_catalog.cpp
+++ b/src/mongo/db/session_catalog.cpp
@@ -254,6 +254,9 @@ OperationContextSession::OperationContextSession(OperationContext* opCtx,
auto& checkedOutSession = operationSessionDecoration(opCtx);
if (!checkedOutSession) {
auto sessionTransactionTable = SessionCatalog::get(opCtx);
+ // We acquire a Client lock here to guard the construction of this session so that
+ // references to this session are safe to use while the lock is held.
+ stdx::lock_guard<Client> lk(*opCtx->getClient());
checkedOutSession.emplace(sessionTransactionTable->checkOutSession(opCtx));
} else {
// The only reason to be trying to check out a session when you already have a session
@@ -281,6 +284,9 @@ OperationContextSession::~OperationContextSession() {
}
auto& checkedOutSession = operationSessionDecoration(_opCtx);
+ // We acquire a Client lock here to guard the destruction of this session so that references to
+ // this session are safe to use while the lock is held.
+ stdx::lock_guard<Client> lk(*_opCtx->getClient());
checkedOutSession.reset();
}