Skip to content

Commit

Permalink
Invert start discovery condition
Browse files Browse the repository at this point in the history
Repeated calls to start_discovery should not start additional topics discovery tasks without stop_discovery calls

Signed-off-by: Øystein Sture <[email protected]>
  • Loading branch information
oysstu committed Jan 9, 2025
1 parent ffd8c7d commit 9fa268d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions rosbag2_transport/src/rosbag2_transport/recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class RecorderImpl

std::mutex start_stop_transition_mutex_;
std::mutex discovery_mutex_;
std::atomic<bool> stop_discovery_ = false;
std::atomic<bool> stop_discovery_ = true;
std::atomic_uchar paused_ = 0;
std::atomic<bool> in_recording_ = false;
std::shared_ptr<KeyboardHandler> keyboard_handler_;
Expand Down Expand Up @@ -441,10 +441,10 @@ void RecorderImpl::start_discovery()
{
std::lock_guard<std::mutex> state_lock(discovery_mutex_);
if (stop_discovery_.exchange(false)) {
RCLCPP_DEBUG(node->get_logger(), "Recorder topic discovery is already running.");
} else {
discovery_future_ =
std::async(std::launch::async, std::bind(&RecorderImpl::topics_discovery, this));
} else {
RCLCPP_DEBUG(node->get_logger(), "Recorder topic discovery is already running.");
}
}

Expand Down

0 comments on commit 9fa268d

Please sign in to comment.