Skip to content

Commit c912d92

Browse files
mergify[bot]saikishorchristophfroehlichdestogl
authored
Add resources_lock_ lock_guards to avoid race condition when loading robot_description through topic (backport #1451) (#1600)
* Add resources_lock_ lock_guards to avoid race condition when loading robot_description through topic (#1451) (cherry picked from commit 25f2c97) # Conflicts: # hardware_interface/src/resource_manager.cpp * Fix merge conflicts * Fix format --------- Co-authored-by: Sai Kishor Kothakota <[email protected]> Co-authored-by: Christoph Fröhlich <[email protected]> Co-authored-by: Dr. Denis <[email protected]>
1 parent 369ba8a commit c912d92

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

hardware_interface/src/resource_manager.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,7 @@ void ResourceManager::load_urdf(
767767
const auto hardware_info = hardware_interface::parse_control_resources_from_urdf(urdf);
768768
if (load_and_initialize_components)
769769
{
770+
std::lock_guard<std::recursive_mutex> resource_guard(resources_lock_);
770771
for (const auto & individual_hardware_info : hardware_info)
771772
{
772773
if (individual_hardware_info.type == actuator_type)
@@ -1287,6 +1288,7 @@ return_type ResourceManager::set_component_state(
12871288
return false;
12881289
};
12891290

1291+
std::lock_guard<std::recursive_mutex> guard(resources_lock_);
12901292
bool found = find_set_component_state(
12911293
std::bind(&ResourceStorage::set_component_state<Actuator>, resource_storage_.get(), _1, _2),
12921294
resource_storage_->actuators_);

0 commit comments

Comments
 (0)