diff --git a/rosbag2_transport/src/rosbag2_transport/recorder.cpp b/rosbag2_transport/src/rosbag2_transport/recorder.cpp index d5d1f0b0e..62a69732b 100644 --- a/rosbag2_transport/src/rosbag2_transport/recorder.cpp +++ b/rosbag2_transport/src/rosbag2_transport/recorder.cpp @@ -328,7 +328,11 @@ void RecorderImpl::record() node->create_publisher("events/write_split", 1); // Start the thread that will publish events - event_publisher_thread_ = std::thread(&RecorderImpl::event_publisher_thread_main, this); + { + std::lock_guard lock(event_publisher_thread_mutex_); + event_publisher_thread_should_exit_ = false; + event_publisher_thread_ = std::thread(&RecorderImpl::event_publisher_thread_main, this); + } rosbag2_cpp::bag_events::WriterEventCallbacks callbacks; callbacks.write_split_callback =