Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ClientData thread-safe #293

Merged
merged 10 commits into from
Nov 12, 2024
2 changes: 1 addition & 1 deletion rmw_zenoh_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ add_library(rmw_zenoh_cpp SHARED
src/detail/logging.cpp
src/detail/message_type_support.cpp
src/detail/qos.cpp
src/detail/rmw_client_data.cpp
src/detail/rmw_context_impl_s.cpp
src/detail/rmw_data_types.cpp
src/detail/rmw_publisher_data.cpp
src/detail/rmw_node_data.cpp
src/detail/rmw_service_data.cpp
Expand Down
9 changes: 4 additions & 5 deletions rmw_zenoh_cpp/src/detail/graph_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

#include "graph_cache.hpp"
#include "logging_macros.hpp"
#include "rmw_data_types.hpp"

namespace rmw_zenoh_cpp
{
Expand Down Expand Up @@ -1182,15 +1181,15 @@ rmw_ret_t GraphCache::get_entities_info_by_topic(

///=============================================================================
rmw_ret_t GraphCache::service_server_is_available(
const char * service_name,
const char * service_type,
const liveliness::TopicInfo & client_topic_info,
Yadunund marked this conversation as resolved.
Show resolved Hide resolved
bool * is_available) const
{
*is_available = false;
std::lock_guard<std::mutex> lock(graph_mutex_);
GraphNode::TopicMap::const_iterator service_it = graph_services_.find(service_name);
GraphNode::TopicMap::const_iterator service_it = graph_services_.find(client_topic_info.name_);
if (service_it != graph_services_.end()) {
GraphNode::TopicTypeMap::const_iterator type_it = service_it->second.find(service_type);
GraphNode::TopicTypeMap::const_iterator type_it =
service_it->second.find(client_topic_info.type_);
if (type_it != service_it->second.end()) {
for (const auto & [_, topic_data] : type_it->second) {
if (topic_data->subs_.size() > 0) {
Expand Down
3 changes: 1 addition & 2 deletions rmw_zenoh_cpp/src/detail/graph_cache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ class GraphCache final
rmw_topic_endpoint_info_array_t * endpoints_info) const;

rmw_ret_t service_server_is_available(
const char * service_name,
const char * service_type,
const liveliness::TopicInfo & client_topic_info,
bool * is_available) const;

/// Set a qos event callback for an entity from the current session.
Expand Down
Loading