Skip to content

Commit

Permalink
Merge branch 'ros2:rolling' into rolling
Browse files Browse the repository at this point in the history
  • Loading branch information
imstevenpmwork authored Aug 8, 2024
2 parents 695d0ea + b78d6a1 commit 8192f62
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
6 changes: 3 additions & 3 deletions rmw_zenoh_cpp/src/detail/graph_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1202,13 +1202,13 @@ 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,
bool * is_available)
bool * is_available) const
{
*is_available = false;
std::lock_guard<std::mutex> lock(graph_mutex_);
GraphNode::TopicMap::iterator service_it = graph_services_.find(service_name);
GraphNode::TopicMap::const_iterator service_it = graph_services_.find(service_name);
if (service_it != graph_services_.end()) {
GraphNode::TopicTypeMap::iterator type_it = service_it.value().find(service_type);
GraphNode::TopicTypeMap::const_iterator type_it = service_it->second.find(service_type);
if (type_it != service_it->second.end()) {
for (const auto & [_, topic_data] : type_it->second) {
if (topic_data->subs_.size() > 0) {
Expand Down
2 changes: 1 addition & 1 deletion rmw_zenoh_cpp/src/detail/graph_cache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class GraphCache final
rmw_ret_t service_server_is_available(
const char * service_name,
const char * service_type,
bool * is_available);
bool * is_available) const;

/// @brief Signature for a function that will be invoked by the GraphCache when a QoS
/// event is detected.
Expand Down
16 changes: 11 additions & 5 deletions rmw_zenoh_cpp/src/zenohd/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@

#include "rmw/error_handling.h"

#include "rcpputils/scope_exit.hpp"

static bool running = true;

class KeyboardReader final
Expand Down Expand Up @@ -192,18 +194,24 @@ int main(int argc, char ** argv)
return 1;
}

z_owned_session_t s = z_open(z_move(config));
if (!z_check(s)) {
z_owned_session_t session = z_open(z_move(config));
if (!z_check(session)) {
printf("Unable to open router session!\n");
return 1;
}
auto always_close_session = rcpputils::make_scope_exit(
[&session]() {
z_close(z_move(session));
});

printf(
"Started Zenoh router with id %s.\n",
rmw_zenoh_cpp::liveliness::zid_to_str(z_info_zid(z_session_loan(&s))).c_str());
rmw_zenoh_cpp::liveliness::zid_to_str(z_info_zid(z_session_loan(&session))).c_str());
#ifdef _WIN32
SetConsoleCtrlHandler(quit, TRUE);
#else
signal(SIGINT, quit);
signal(SIGTERM, quit);
#endif

KeyboardReader keyreader;
Expand All @@ -227,7 +235,5 @@ int main(int argc, char ** argv)
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}

z_close(z_move(s));

return 0;
}

0 comments on commit 8192f62

Please sign in to comment.