Skip to content

Commit

Permalink
Add workaround for publishers not being cleaned up after they got des…
Browse files Browse the repository at this point in the history
…troyed (foxglove#215)

### Public-Facing Changes
- Add workaround for publishers not being cleaned up after they got
destroyed

### Description
Fixes publishers not being fully destroyed if there is no event
triggering the actual cleanup. See
ros2/rclcpp#2146 (comment)
  • Loading branch information
achim-k committed Apr 14, 2023
1 parent aaf557f commit daa0e01
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ros2_foxglove_bridge/src/ros2_foxglove_bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,11 @@ class FoxgloveBridge : public rclcpp::Node {
if (clientPublications.empty()) {
_clientAdvertisedTopics.erase(it);
}

// Create a timer that immedeately goes out of scope (so it never fires) which will trigger
// the previously destroyed publisher to be cleaned up. This is a workaround for
// https://github.com/ros2/rclcpp/issues/2146
this->create_wall_timer(1s, []() {});
}

void clientMessage(const foxglove::ClientMessage& message, ConnectionHandle hdl) {
Expand Down

0 comments on commit daa0e01

Please sign in to comment.