diff options
author | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2018-11-01 18:51:15 -0400 |
---|---|---|
committer | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2018-11-08 18:35:00 -0500 |
commit | aff889b39301472bd2143967938a3dba468dfc63 (patch) | |
tree | 2ee4fcec926d96a674690e390d5b916b4b9c7a3b /src/mongo/db/session_catalog_test.cpp | |
parent | 4fb38d9c10123321dada6fe1be477f9cb99732a7 (diff) | |
download | mongo-aff889b39301472bd2143967938a3dba468dfc63.tar.gz |
SERVER-36473 Make a dedicated RAII class to manage Client lifetime
Diffstat (limited to 'src/mongo/db/session_catalog_test.cpp')
-rw-r--r-- | src/mongo/db/session_catalog_test.cpp | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/mongo/db/session_catalog_test.cpp b/src/mongo/db/session_catalog_test.cpp index c5e4a52b7c6..1f8312b6e69 100644 --- a/src/mongo/db/session_catalog_test.cpp +++ b/src/mongo/db/session_catalog_test.cpp @@ -123,8 +123,7 @@ TEST_F(SessionCatalogTestWithDefaultOpCtx, GetOrCreateSessionAfterCheckOutSessio ocs.emplace(_opCtx, true); stdx::async(stdx::launch::async, [&] { - ON_BLOCK_EXIT([&] { Client::destroy(); }); - Client::initThreadIfNotAlready(); + ThreadClient tc(getGlobalServiceContext()); auto sideOpCtx = Client::getCurrent()->makeOperationContext(); auto scopedSession = SessionCatalog::get(sideOpCtx.get())->getOrCreateSession(sideOpCtx.get(), lsid); @@ -136,8 +135,7 @@ TEST_F(SessionCatalogTestWithDefaultOpCtx, GetOrCreateSessionAfterCheckOutSessio ocs.reset(); stdx::async(stdx::launch::async, [&] { - ON_BLOCK_EXIT([&] { Client::destroy(); }); - Client::initThreadIfNotAlready(); + ThreadClient tc(getGlobalServiceContext()); auto sideOpCtx = Client::getCurrent()->makeOperationContext(); auto scopedSession = SessionCatalog::get(sideOpCtx.get())->getOrCreateSession(sideOpCtx.get(), lsid); @@ -234,8 +232,7 @@ TEST_F(SessionCatalogTest, KillSessionWhenSessionIsNotCheckedOut) { // Schedule a separate "regular operation" thread, which will block on checking-out the session, // which we will use to confirm that session kill completion actually unblocks check-out auto future = stdx::async(stdx::launch::async, [lsid] { - ON_BLOCK_EXIT([&] { Client::destroy(); }); - Client::initThreadIfNotAlready(); + ThreadClient tc(getGlobalServiceContext()); auto sideOpCtx = Client::getCurrent()->makeOperationContext(); sideOpCtx->setLogicalSessionId(lsid); @@ -279,8 +276,7 @@ TEST_F(SessionCatalogTest, KillSessionWhenSessionIsCheckedOut) { // Make sure that the checkOutForKill call will wait for the owning operation context to // check the session back in auto future = stdx::async(stdx::launch::async, [lsid] { - ON_BLOCK_EXIT([&] { Client::destroy(); }); - Client::initThreadIfNotAlready(); + ThreadClient tc(getGlobalServiceContext()); auto sideOpCtx = Client::getCurrent()->makeOperationContext(); sideOpCtx->setLogicalSessionId(lsid); sideOpCtx->setDeadlineAfterNowBy(Milliseconds(10), ErrorCodes::MaxTimeMSExpired); @@ -306,8 +302,7 @@ TEST_F(SessionCatalogTest, KillSessionWhenSessionIsCheckedOut) { // Schedule a separate "regular operation" thread, which will block on checking-out the session, // which we will use to confirm that session kill completion actually unblocks check-out auto future = stdx::async(stdx::launch::async, [lsid] { - ON_BLOCK_EXIT([&] { Client::destroy(); }); - Client::initThreadIfNotAlready(); + ThreadClient tc(getGlobalServiceContext()); auto sideOpCtx = Client::getCurrent()->makeOperationContext(); sideOpCtx->setLogicalSessionId(lsid); @@ -387,8 +382,7 @@ TEST_F(SessionCatalogTestWithDefaultOpCtx, KillSessionsThroughScanSessions) { for (const auto& lsid : lsids) { futures.emplace_back( stdx::async(stdx::launch::async, [lsid, &firstUseOfTheSessionReachedBarrier] { - ON_BLOCK_EXIT([&] { Client::destroy(); }); - Client::initThreadIfNotAlready(); + ThreadClient tc(getGlobalServiceContext()); { auto sideOpCtx = Client::getCurrent()->makeOperationContext(); |