Skip to content

Commit 41fedb7

Browse files
authored
Fix race condition in TimeSource clock thread setup (ros2#1623)
Signed-off-by: Michel Hidalgo <[email protected]>
1 parent 98fc7fe commit 41fedb7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

rclcpp/src/rclcpp/time_source.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,9 @@ void TimeSource::create_clock_sub()
261261
clock_executor_ =
262262
std::make_shared<rclcpp::executors::SingleThreadedExecutor>(exec_options);
263263
if (!clock_executor_thread_.joinable()) {
264+
cancel_clock_executor_promise_ = std::promise<void>{};
264265
clock_executor_thread_ = std::thread(
265266
[this]() {
266-
cancel_clock_executor_promise_ = std::promise<void>{};
267267
auto future = cancel_clock_executor_promise_.get_future();
268268
clock_executor_->add_callback_group(clock_callback_group_, node_base_);
269269
clock_executor_->spin_until_future_complete(future);

0 commit comments

Comments
 (0)