diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-05-26 15:40:09 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2023-05-26 15:40:09 +0000 |
commit | 8d3fdc2184e07cbc5b46d297c02bf88f5c2e8c42 (patch) | |
tree | 8d7a9c0709724d8d5f4add90a96770a355ee06f3 /searchcore | |
parent | dda025899b05bf73e99d5d50a9681beb73469955 (diff) |
Prevent possible deadlock when calling State::cancel by dropping the taskList lock first.
Diffstat (limited to 'searchcore')
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/common/scheduled_forward_executor.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/common/scheduled_forward_executor.cpp b/searchcore/src/vespa/searchcore/proton/common/scheduled_forward_executor.cpp index f19ff36dbfb..230ff922e80 100644 --- a/searchcore/src/vespa/searchcore/proton/common/scheduled_forward_executor.cpp +++ b/searchcore/src/vespa/searchcore/proton/common/scheduled_forward_executor.cpp @@ -95,11 +95,15 @@ ScheduledForwardExecutor::~ScheduledForwardExecutor() { bool ScheduledForwardExecutor::cancel(uint64_t key) { - std::lock_guard guard(_lock); - auto found = _taskList.find(key); - if (found == _taskList.end()) return false; - found->second->cancel(); - _taskList.erase(found); + std::unique_ptr<State> state; + { + std::lock_guard guard(_lock); + auto found = _taskList.find(key); + if (found == _taskList.end()) return false; + state = std::move(found->second); + _taskList.erase(found); + } + state->cancel(); return true; } |