summaryrefslogtreecommitdiff
path: root/src/mongo/db/service_context.cpp
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2017-04-04 15:59:49 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2017-04-05 12:44:10 -0400
commit8765acc0fcc6ca3dd7158521ba8d864af4e0f2df (patch)
tree9fc35ffc0f93b334bbc846cb6ccf91250ae11252 /src/mongo/db/service_context.cpp
parent97691221bcf43245ddfd906766abc93bb617d2aa (diff)
downloadmongo-8765acc0fcc6ca3dd7158521ba8d864af4e0f2df.tar.gz
SERVER-27691 Make OperationContext::setKillAllOperations interrupt all operations
Diffstat (limited to 'src/mongo/db/service_context.cpp')
-rw-r--r--src/mongo/db/service_context.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/mongo/db/service_context.cpp b/src/mongo/db/service_context.cpp
index 1509fca8367..de50199c149 100644
--- a/src/mongo/db/service_context.cpp
+++ b/src/mongo/db/service_context.cpp
@@ -293,7 +293,20 @@ void appendStorageEngineList(BSONObjBuilder* result) {
void ServiceContext::setKillAllOperations() {
stdx::lock_guard<stdx::mutex> clientLock(_mutex);
+
+ // Ensure that all newly created operation contexts will immediately be in the interrupted state
_globalKill.store(true);
+
+ // Interrupt all active operations
+ for (auto&& client : _clients) {
+ stdx::lock_guard<Client> lk(*client);
+ auto opCtxToKill = client->getOperationContext();
+ if (opCtxToKill) {
+ killOperation(opCtxToKill, ErrorCodes::InterruptedAtShutdown);
+ }
+ }
+
+ // Notify any listeners who need to reach to the server shutting down
for (const auto listener : _killOpListeners) {
try {
listener->interruptAll();