Fix action server deadlock issue that caused by other mutexes locked in CancelCallback (#1635) (#1654)
Signed-off-by: Kaven Yau <kavenyau@foxmail.com>
This commit is contained in:
parent
6ceeff0f0f
commit
791c23afe5
1 changed files with 13 additions and 9 deletions
|
@ -351,19 +351,23 @@ protected:
|
||||||
/// \internal
|
/// \internal
|
||||||
CancelResponse
|
CancelResponse
|
||||||
call_handle_cancel_callback(const GoalUUID & uuid) override
|
call_handle_cancel_callback(const GoalUUID & uuid) override
|
||||||
|
{
|
||||||
|
std::shared_ptr<ServerGoalHandle<ActionT>> goal_handle;
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(goal_handles_mutex_);
|
std::lock_guard<std::mutex> lock(goal_handles_mutex_);
|
||||||
CancelResponse resp = CancelResponse::REJECT;
|
|
||||||
auto element = goal_handles_.find(uuid);
|
auto element = goal_handles_.find(uuid);
|
||||||
if (element != goal_handles_.end()) {
|
if (element != goal_handles_.end()) {
|
||||||
std::shared_ptr<ServerGoalHandle<ActionT>> goal_handle = element->second.lock();
|
goal_handle = element->second.lock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CancelResponse resp = CancelResponse::REJECT;
|
||||||
if (goal_handle) {
|
if (goal_handle) {
|
||||||
resp = handle_cancel_(goal_handle);
|
resp = handle_cancel_(goal_handle);
|
||||||
if (CancelResponse::ACCEPT == resp) {
|
if (CancelResponse::ACCEPT == resp) {
|
||||||
goal_handle->_cancel_goal();
|
goal_handle->_cancel_goal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue