summaryrefslogtreecommitdiff
path: root/src/mongo/executor/connection_pool.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/executor/connection_pool.cpp')
-rw-r--r--src/mongo/executor/connection_pool.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/mongo/executor/connection_pool.cpp b/src/mongo/executor/connection_pool.cpp
index 43d061db5a8..c00fe1c739b 100644
--- a/src/mongo/executor/connection_pool.cpp
+++ b/src/mongo/executor/connection_pool.cpp
@@ -280,7 +280,9 @@ ConnectionPool::ConnectionPool(std::unique_ptr<DependentTypeFactoryInterface> im
}
ConnectionPool::~ConnectionPool() {
- if (_manager) {
+ // If we're currently destroying the service context the _manager is already deleted and this
+ // pointer dangles. No need for cleanup in that case.
+ if (hasGlobalServiceContext() && _manager) {
_manager->remove(this);
}
}