diff options
author | Martin Neupauer <martin.neupauer@mongodb.com> | 2018-01-18 12:04:01 -0500 |
---|---|---|
committer | Martin Neupauer <martin.neupauer@mongodb.com> | 2018-01-31 15:05:08 -0500 |
commit | 15a7ac9ca54f2d580e2b1d1ab01fe095be1233db (patch) | |
tree | c3628b0d5be60aa6bd911c8c351daa9606f6b060 /src/mongo/executor/thread_pool_task_executor.cpp | |
parent | 3c349c50d8d5a55fa80c1d7ae3ac6a6f6cc82b5e (diff) | |
download | mongo-15a7ac9ca54f2d580e2b1d1ab01fe095be1233db.tar.gz |
SERVER-31484 separate the operation deadline from awaitData deadline in sharded queries.
The deadline has been been already separated for non-sharded queries.
Diffstat (limited to 'src/mongo/executor/thread_pool_task_executor.cpp')
-rw-r--r-- | src/mongo/executor/thread_pool_task_executor.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/mongo/executor/thread_pool_task_executor.cpp b/src/mongo/executor/thread_pool_task_executor.cpp index 4e6dc5f45fb..202de888b5a 100644 --- a/src/mongo/executor/thread_pool_task_executor.cpp +++ b/src/mongo/executor/thread_pool_task_executor.cpp @@ -285,22 +285,26 @@ StatusWith<TaskExecutor::CallbackHandle> ThreadPoolTaskExecutor::onEvent(const E return cbHandle; } -Status ThreadPoolTaskExecutor::waitForEvent(OperationContext* opCtx, const EventHandle& event) { +StatusWith<stdx::cv_status> ThreadPoolTaskExecutor::waitForEvent(OperationContext* opCtx, + const EventHandle& event, + Date_t deadline) { invariant(opCtx); invariant(event.isValid()); auto eventState = checked_cast<EventState*>(getEventFromHandle(event)); stdx::unique_lock<stdx::mutex> lk(_mutex); - try { - // std::condition_variable::wait() can wake up spuriously, so provide a callback to detect - // when that happens and go back to waiting. - opCtx->waitForConditionOrInterrupt(eventState->isSignaledCondition, lk, [&eventState]() { - return eventState->isSignaledFlag; - }); - } catch (const DBException& e) { - return e.toStatus(); + // std::condition_variable::wait() can wake up spuriously, so we have to loop until the event + // is signalled or we time out. + while (!eventState->isSignaledFlag) { + auto status = opCtx->waitForConditionOrInterruptNoAssertUntil( + eventState->isSignaledCondition, lk, deadline); + + if (!status.isOK() || stdx::cv_status::timeout == status) { + return status; + } } - return Status::OK(); + + return stdx::cv_status::no_timeout; } void ThreadPoolTaskExecutor::waitForEvent(const EventHandle& event) { |