summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Nelson <lamont.nelson@mongodb.com>2020-02-24 22:41:31 -0500
committerLamont Nelson <lamont.nelson@mongodb.com>2020-02-24 22:41:31 -0500
commitd7da8829b461f539b6e92b7e3f56038a8fbd362f (patch)
tree12f7f368c43658c16426850aa490f2a58dd9dba3
parent068de9cd81d4146083979ac0e924519c91bf5845 (diff)
downloadmongo-d7da8829b461f539b6e92b7e3f56038a8fbd362f.tar.gz
fix shutdown of single sever monitor
-rw-r--r--src/mongo/client/server_is_master_monitor.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/mongo/client/server_is_master_monitor.cpp b/src/mongo/client/server_is_master_monitor.cpp
index 4c50355b6d5..9a960722651 100644
--- a/src/mongo/client/server_is_master_monitor.cpp
+++ b/src/mongo/client/server_is_master_monitor.cpp
@@ -200,9 +200,11 @@ void SingleServerIsMasterMonitor::_doRemoteCommand() {
void SingleServerIsMasterMonitor::shutdown() {
stdx::lock_guard lock(_mutex);
+ if (std::exchange(_isShutdown, true))
+ return;
+
LOG(kLogLevel.lessSevere()) << "Closing Replica Set SingleServerIsMasterMonitor for host "
<< _host;
- _isShutdown = true;
_cancelOutstandingRequest(lock);
@@ -212,11 +214,11 @@ void SingleServerIsMasterMonitor::shutdown() {
}
void SingleServerIsMasterMonitor::_cancelOutstandingRequest(WithLock) {
- if (_nextIsMasterHandle.isValid()) {
+ if (_nextIsMasterHandle) {
_executor->cancel(_nextIsMasterHandle);
}
- if (_remoteCommandHandle.isValid()) {
+ if (_remoteCommandHandle) {
_executor->cancel(_remoteCommandHandle);
}