diff --git a/rmw_cyclonedds_cpp/src/rmw_node.cpp b/rmw_cyclonedds_cpp/src/rmw_node.cpp index 094f7e2c..fc232850 100644 --- a/rmw_cyclonedds_cpp/src/rmw_node.cpp +++ b/rmw_cyclonedds_cpp/src/rmw_node.cpp @@ -2221,8 +2221,10 @@ static void clean_waitset_caches() used ... */ std::lock_guard lock(gcdds.lock); for (auto && ws : gcdds.waitsets) { - std::lock_guard lock2(ws->lock); - waitset_detach(ws); + std::unique_lock lock2(ws->lock, std::try_to_lock); + if (lock2.owns_lock()) { + waitset_detach(ws); + } } }