diff --git a/rosbag2_transport/src/rosbag2_transport/recorder.cpp b/rosbag2_transport/src/rosbag2_transport/recorder.cpp index 4d0c2649a1..7f72a43b94 100644 --- a/rosbag2_transport/src/rosbag2_transport/recorder.cpp +++ b/rosbag2_transport/src/rosbag2_transport/recorder.cpp @@ -116,9 +116,11 @@ Recorder::~Recorder() stop(); } - void Recorder::stop() { + if (event_publisher_thread_should_exit_) { + return; // We are not in recording and therefore shall not do stop operation. + } stop_discovery_ = true; if (discovery_future_.valid()) { auto status = discovery_future_.wait_for(2 * record_options_.topic_polling_interval); @@ -146,6 +148,7 @@ void Recorder::stop() void Recorder::record() { + event_publisher_thread_should_exit_ = false; stop_discovery_ = record_options_.is_discovery_disabled; paused_ = record_options_.start_paused; topic_qos_profile_overrides_ = record_options_.topic_qos_profile_overrides;