diff options
author | Andrew Shuvalov <andrew.shuvalov@mongodb.com> | 2021-01-15 17:32:29 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-01-19 20:41:30 +0000 |
commit | 457c2faf499e465bbecabd02701f2b08b681c3f8 (patch) | |
tree | d5af82f1f6488794b2840e45e96e9344aed117f1 /src/mongo | |
parent | aa42bdce4f3da6727480155de0f0bc10fb548b79 (diff) | |
download | mongo-457c2faf499e465bbecabd02701f2b08b681c3f8.tar.gz |
SERVER-53830: fix synchronization in replica_set_monitor_integration_test.cpp
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/client/replica_set_monitor_integration_test.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/mongo/client/replica_set_monitor_integration_test.cpp b/src/mongo/client/replica_set_monitor_integration_test.cpp index 9dd0c8f1089..f426b1d6f12 100644 --- a/src/mongo/client/replica_set_monitor_integration_test.cpp +++ b/src/mongo/client/replica_set_monitor_integration_test.cpp @@ -173,9 +173,13 @@ TEST_F(ReplicaSetMonitorFixture, ReplicaSetMonitorCleanup) { auto sets = ReplicaSetMonitorManager::get()->getAllSetNames(); ASSERT_TRUE(std::find(sets.begin(), sets.end(), setName) == sets.end()); + Mutex mutex; bool cleanupInvoked = false; - auto rsm = ReplicaSetMonitorManager::get()->getOrCreateMonitor( - replSetUri, [&cleanupInvoked] { cleanupInvoked = true; }); + auto rsm = + ReplicaSetMonitorManager::get()->getOrCreateMonitor(replSetUri, [&cleanupInvoked, &mutex] { + stdx::lock_guard<Latch> lk(mutex); + cleanupInvoked = true; + }); sets = ReplicaSetMonitorManager::get()->getAllSetNames(); ASSERT_TRUE(std::find(sets.begin(), sets.end(), setName) != sets.end()); @@ -183,6 +187,7 @@ TEST_F(ReplicaSetMonitorFixture, ReplicaSetMonitorCleanup) { shutdownExecutor(); rsm.reset(); + stdx::lock_guard<Latch> lk(mutex); ASSERT_TRUE(cleanupInvoked); } |