diff --git a/rclcpp/src/rclcpp/context.cpp b/rclcpp/src/rclcpp/context.cpp index 90ea3db908..7e4c28da1c 100644 --- a/rclcpp/src/rclcpp/context.cpp +++ b/rclcpp/src/rclcpp/context.cpp @@ -344,6 +344,7 @@ Context::shutdown(const std::string & reason) rclcpp::Context::OnShutdownCallback Context::on_shutdown(OnShutdownCallback callback) { + std::lock_guard lock(on_shutdown_callbacks_mutex_); on_shutdown_callbacks_.push_back(callback); return callback; }