diff options
Diffstat (limited to 'src/mongo/db/operation_context.cpp')
-rw-r--r-- | src/mongo/db/operation_context.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/mongo/db/operation_context.cpp b/src/mongo/db/operation_context.cpp index ee38faab01b..a0bee37b49b 100644 --- a/src/mongo/db/operation_context.cpp +++ b/src/mongo/db/operation_context.cpp @@ -203,10 +203,17 @@ bool opShouldFail(Client* client, const BSONObj& failPointInfo) { } // namespace Status OperationContext::checkForInterruptNoAssert() noexcept { - // TODO: Remove the MONGO_likely(getClient()) once all operation contexts are constructed with - // clients. - if (MONGO_likely(getClient() && getServiceContext()) && - getServiceContext()->getKillAllOperations() && !_isExecutingShutdown) { + // TODO: Remove the MONGO_likely(hasClientAndServiceContext) once all operation contexts are + // constructed with clients. + const auto hasClientAndServiceContext = getClient() && getServiceContext(); + + if (MONGO_likely(hasClientAndServiceContext) && getClient()->getKilled() && + !_isExecutingShutdown) { + return Status(ErrorCodes::ClientMarkedKilled, "client has been killed"); + } + + if (MONGO_likely(hasClientAndServiceContext) && getServiceContext()->getKillAllOperations() && + !_isExecutingShutdown) { return Status(ErrorCodes::InterruptedAtShutdown, "interrupted at shutdown"); } |