diff options
Diffstat (limited to 'src/mongo/executor/thread_pool_task_executor.cpp')
-rw-r--r-- | src/mongo/executor/thread_pool_task_executor.cpp | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/mongo/executor/thread_pool_task_executor.cpp b/src/mongo/executor/thread_pool_task_executor.cpp index fefecf9a04e..9496b88d21f 100644 --- a/src/mongo/executor/thread_pool_task_executor.cpp +++ b/src/mongo/executor/thread_pool_task_executor.cpp @@ -597,7 +597,9 @@ void ThreadPoolTaskExecutor::scheduleIntoPool_inlock(WorkQueue* fromQueue, if (MONGO_FAIL_POINT(scheduleIntoPoolSpinsUntilThreadPoolShutsDown)) { scheduleIntoPoolSpinsUntilThreadPoolShutsDown.setMode(FailPoint::off); - while (_pool->schedule([] {}) != ErrorCodes::ShutdownInProgress) { + + auto checkStatus = [&] { return _pool->execute([] {}).getNoThrow(); }; + while (!ErrorCodes::isCancelationError(checkStatus().code())) { sleepmillis(100); } } @@ -611,16 +613,24 @@ void ThreadPoolTaskExecutor::scheduleIntoPool_inlock(WorkQueue* fromQueue, } cbState->canceled.store(1); - const auto status = - _pool->schedule([this, cbState] { runCallback(std::move(cbState)); }); - invariant(status.isOK() || status == ErrorCodes::ShutdownInProgress); + _pool->schedule([this, cbState](auto status) { + invariant(status.isOK() || ErrorCodes::isCancelationError(status.code())); + + runCallback(std::move(cbState)); + }); }); } else { - const auto status = - _pool->schedule([this, cbState] { runCallback(std::move(cbState)); }); - if (status == ErrorCodes::ShutdownInProgress) - break; - fassert(28735, status); + _pool->schedule([this, cbState](auto status) { + if (ErrorCodes::isCancelationError(status.code())) { + stdx::lock_guard<stdx::mutex> lk(_mutex); + + cbState->canceled.store(1); + } else { + fassert(28735, status); + } + + runCallback(std::move(cbState)); + }); } } _net->signalWorkAvailable(); |