Skip to content

Commit

Permalink
Fix lock-order-inversion (potential deadlock) (ros2#1135)
Browse files Browse the repository at this point in the history
Signed-off-by: Tomoya.Fujita <Tomoya.Fujita@sony.com>
  • Loading branch information
fujitatomoya committed May 28, 2020
1 parent 3e5b6a4 commit 039b1ae
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions rclcpp/src/rclcpp/node_interfaces/node_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,11 @@ rclcpp::Event::SharedPtr
NodeGraph::get_graph_event()
{
auto event = rclcpp::Event::make_shared();
std::lock_guard<std::mutex> graph_changed_lock(graph_mutex_);
graph_events_.push_back(event);
graph_users_count_++;
{
std::lock_guard<std::mutex> graph_changed_lock(graph_mutex_);
graph_events_.push_back(event);
graph_users_count_++;
}
// on first call, add node to graph_listener_
if (should_add_to_graph_listener_.exchange(false)) {
graph_listener_->add_node(this);
Expand Down

0 comments on commit 039b1ae

Please sign in to comment.