Skip to content

Commit 847e655

Browse files
mergify[bot]saikishordestoglchristophfroehlich
authored
Add resources_lock_ lock_guards to avoid race condition when loading robot_description through topic (backport #1451) (#1599)
* 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 * Try fixing conflict. --------- Co-authored-by: Sai Kishor Kothakota <[email protected]> Co-authored-by: Dr. Denis <[email protected]> Co-authored-by: Christoph Fröhlich <[email protected]>
1 parent cd55739 commit 847e655

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
@@ -686,6 +686,7 @@ void ResourceManager::load_urdf(
686686

687687
const auto hardware_info = hardware_interface::parse_control_resources_from_urdf(urdf);
688688
if (load_and_initialize_components)
689+
std::lock_guard<std::recursive_mutex> resource_guard(resources_lock_);
689690
{
690691
for (const auto & individual_hardware_info : hardware_info)
691692
{
@@ -1209,6 +1210,7 @@ return_type ResourceManager::set_component_state(
12091210
return false;
12101211
};
12111212

1213+
std::lock_guard<std::recursive_mutex> guard(resources_lock_);
12121214
bool found = find_set_component_state(
12131215
std::bind(&ResourceStorage::set_component_state<Actuator>, resource_storage_.get(), _1, _2),
12141216
resource_storage_->actuators_);

0 commit comments

Comments
 (0)