Skip to content

Commit

Permalink
Merge pull request ros2#59 from mauropasse/mauro/fix-deadlock
Browse files Browse the repository at this point in the history
Unlock queue mutex after taking event
  • Loading branch information
iRobot ROS authored Mar 29, 2021
2 parents 02f4365 + b25bef8 commit 2fe825b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class EventsQueue
* @brief gets a single entity event from the queue
* @return a single entity event
*/
// TODO: find an alternative to pop_all_events and
// TODO(mauropasse): find an alternative to pop_all_events and
// get_single_event to use standard queue interfaces
RCLCPP_PUBLIC
virtual
Expand Down
3 changes: 3 additions & 0 deletions rclcpp/src/rclcpp/executors/events_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ EventsExecutor::spin_some_impl(std::chrono::nanoseconds max_duration, bool exhau
if (has_event) {
ExecutorEvent event = events_queue_->front();
events_queue_->pop();
// Unlock the mutex, so if the execution of the event requires
// pushing an event into the queue we avoid a deadlock.
lock.unlock();
this->execute_event(event);
executed_events++;
continue;
Expand Down

0 comments on commit 2fe825b

Please sign in to comment.