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

Bump zenoh-c version. #30

Merged
merged 2 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions rmw_zenoh_cpp/src/detail/attachment_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ attachement_data_t::attachement_data_t(const z_loaned_bytes_t * attachment)
ze_deserializer_deserialize_string(&deserializer, &key);

// Deserialize the sequence_number
if (std::string_view(z_string_data(z_loan(key)),
if (std::string_view(
z_string_data(z_loan(key)),
z_string_len(z_loan(key))) != "sequence_number")
{
throw std::runtime_error("sequence_number is not found in the attachment.");
Expand All @@ -77,7 +78,8 @@ attachement_data_t::attachement_data_t(const z_loaned_bytes_t * attachment)

// Deserialize the source_timestamp
ze_deserializer_deserialize_string(&deserializer, &key);
if (std::string_view(z_string_data(z_loan(key)),
if (std::string_view(
z_string_data(z_loan(key)),
z_string_len(z_loan(key))) != "source_timestamp")
{
throw std::runtime_error("source_timestamp is not found in the attachment");
Expand Down
7 changes: 4 additions & 3 deletions rmw_zenoh_cpp/src/detail/rmw_context_impl_s.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ rmw_ret_t rmw_context_impl_s::Data::subscribe_to_ros_graph()
z_undeclare_subscriber(z_move(this->graph_subscriber_));
});
if (zc_liveliness_declare_subscriber(
&graph_subscriber_,
z_loan(session_), z_loan(keyexpr),
z_loan(session_),
&graph_subscriber_, z_loan(keyexpr),
z_move(callback), &sub_options) != Z_OK)
{
RMW_SET_ERROR_MSG("unable to create zenoh subscription");
Expand Down Expand Up @@ -333,7 +333,8 @@ rmw_context_impl_s::rmw_context_impl_s(
}

///=============================================================================
rmw_context_impl_s::~rmw_context_impl_s() {
rmw_context_impl_s::~rmw_context_impl_s()
{
// std::lock_guard<std::recursive_mutex> lock(data_->mutex_);
// z_drop(z_move(data_->session_));
}
Expand Down
2 changes: 1 addition & 1 deletion rmw_zenoh_cpp/src/detail/rmw_node_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ std::shared_ptr<NodeData> NodeData::make(
[&token]() {
z_drop(z_move(token));
});
if (zc_liveliness_declare_token(&token, session, z_loan(liveliness_ke), NULL) != Z_OK) {
if (zc_liveliness_declare_token(session, &token, z_loan(liveliness_ke), NULL) != Z_OK) {
RMW_ZENOH_LOG_ERROR_NAMED(
"rmw_zenoh_cpp",
"Unable to create liveliness token for the node.");
Expand Down
18 changes: 10 additions & 8 deletions rmw_zenoh_cpp/src/detail/rmw_publisher_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ std::shared_ptr<PublisherData> PublisherData::make(

ze_owned_publication_cache_t pub_cache_;
if (ze_declare_publication_cache(
&pub_cache_, session, z_loan(pub_ke), &pub_cache_opts))
session, &pub_cache_, z_loan(pub_ke), &pub_cache_opts))
{
RMW_SET_ERROR_MSG("unable to create zenoh publisher cache");
return nullptr;
Expand All @@ -159,7 +159,7 @@ std::shared_ptr<PublisherData> PublisherData::make(
z_undeclare_publisher(z_move(pub));
});
if (z_declare_publisher(
&pub, session, z_loan(pub_ke), &opts) != Z_OK)
session, &pub, z_loan(pub_ke), &opts) != Z_OK)
{
RMW_SET_ERROR_MSG("Unable to create Zenoh publisher.");
return nullptr;
Expand All @@ -174,7 +174,7 @@ std::shared_ptr<PublisherData> PublisherData::make(
z_drop(z_move(token));
});
if (zc_liveliness_declare_token(
&token, session, z_loan(liveliness_ke),
session, &token, z_loan(liveliness_ke),
NULL) != Z_OK)
{
RMW_ZENOH_LOG_ERROR_NAMED(
Expand Down Expand Up @@ -253,7 +253,7 @@ rmw_ret_t PublisherData::publish(
if (shmbuf.has_value()) {
z_drop(z_move(shmbuf.value()));
}
});
});

rcutils_allocator_t * allocator = &rmw_node_->context->options.allocator;

Expand Down Expand Up @@ -324,8 +324,9 @@ rmw_ret_t PublisherData::publish(
z_result_t res = z_publisher_put(z_loan(pub_), z_move(payload), &options);
if (res != Z_OK) {
if (res == Z_ESESSION_CLOSED) {
RMW_ZENOH_LOG_WARN_NAMED("rmw_zenoh_cpp",
"unable to publish message since the zenoh session is closed");
RMW_ZENOH_LOG_WARN_NAMED(
"rmw_zenoh_cpp",
"unable to publish message since the zenoh session is closed");
} else {
RMW_SET_ERROR_MSG("unable to publish message");
return RMW_RET_ERROR;
Expand Down Expand Up @@ -368,8 +369,9 @@ rmw_ret_t PublisherData::publish_serialized_message(
z_result_t res = z_publisher_put(z_loan(pub_), z_move(payload), &options);
if (res != Z_OK) {
if (res == Z_ESESSION_CLOSED) {
RMW_ZENOH_LOG_WARN_NAMED("rmw_zenoh_cpp",
"unable to publish message since the zenoh session is closed");
RMW_ZENOH_LOG_WARN_NAMED(
"rmw_zenoh_cpp",
"unable to publish message since the zenoh session is closed");
} else {
RMW_SET_ERROR_MSG("unable to publish message");
return RMW_RET_ERROR;
Expand Down
14 changes: 8 additions & 6 deletions rmw_zenoh_cpp/src/detail/rmw_subscription_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ std::shared_ptr<SubscriptionData> SubscriptionData::make(
// Make the initial query to hit all the PublicationCaches, using a query_selector with
// '*' in place of the queryable_prefix of each PublicationCache
const std::string selector = "*/" +
sub_data->entity_->topic_info()->topic_keyexpr_;
sub_data->entity_->topic_info()->topic_keyexpr_;
z_view_keyexpr_t selector_ke;
z_view_keyexpr_from_str(&selector_ke, selector.c_str());
sub_options.query_selector = z_loan(selector_ke);
Expand All @@ -220,7 +220,7 @@ std::shared_ptr<SubscriptionData> SubscriptionData::make(
sub_options.query_consolidation = z_query_consolidation_none();
ze_owned_querying_subscriber_t sub;
if (ze_declare_querying_subscriber(
&sub, session, z_loan(sub_ke), z_move(callback), &sub_options))
session, &sub, z_loan(sub_ke), z_move(callback), &sub_options))
{
RMW_SET_ERROR_MSG("unable to create zenoh subscription");
return nullptr;
Expand Down Expand Up @@ -274,7 +274,7 @@ std::shared_ptr<SubscriptionData> SubscriptionData::make(

z_owned_subscriber_t sub;
if (z_declare_subscriber(
&sub, session, z_loan(sub_ke), z_move(callback),
session, &sub, z_loan(sub_ke), z_move(callback),
&sub_options) != Z_OK)
{
RMW_SET_ERROR_MSG("unable to create zenoh subscription");
Expand All @@ -291,11 +291,11 @@ std::shared_ptr<SubscriptionData> SubscriptionData::make(
auto free_token = rcpputils::make_scope_exit(
[sub_data]() {
if (sub_data != nullptr) {
z_drop(z_move(sub_data->token_ ));
z_drop(z_move(sub_data->token_));
}
});
if (zc_liveliness_declare_token(
&sub_data->token_, session, z_loan(liveliness_ke), NULL) != Z_OK)
session, &sub_data->token_, z_loan(liveliness_ke), NULL) != Z_OK)
{
RMW_ZENOH_LOG_ERROR_NAMED(
"rmw_zenoh_cpp",
Expand Down Expand Up @@ -556,7 +556,9 @@ void SubscriptionData::add_new_message(
const size_t gid_hash = hash_gid(msg->attachment.source_gid);
auto last_known_pub_it = last_known_published_msg_.find(gid_hash);
if (last_known_pub_it != last_known_published_msg_.end()) {
const int64_t seq_increment = std::abs(msg->attachment.sequence_number - last_known_pub_it->second);
const int64_t seq_increment = std::abs(
msg->attachment.sequence_number -
last_known_pub_it->second);
if (seq_increment > 1) {
const size_t num_msg_lost = seq_increment - 1;
total_messages_lost_ += num_msg_lost;
Expand Down
16 changes: 9 additions & 7 deletions rmw_zenoh_cpp/src/rmw_zenoh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1609,7 +1609,7 @@ rmw_create_client(
}
});
if (zc_liveliness_declare_token(
&client_data->token, session, z_loan(liveliness_ke),
session, &client_data->token, z_loan(liveliness_ke),
NULL) != Z_OK)
{
RMW_ZENOH_LOG_ERROR_NAMED(
Expand Down Expand Up @@ -1764,8 +1764,9 @@ rmw_send_request(
z_get_options_default(&opts);

z_owned_bytes_t attachment;
rmw_zenoh_cpp::create_map_and_set_sequence_num(&attachment, *sequence_id,
client_data->client_gid);
rmw_zenoh_cpp::create_map_and_set_sequence_num(
&attachment, *sequence_id,
client_data->client_gid);
auto free_attachment = rcpputils::make_scope_exit(
[&attachment]() {
z_drop(z_move(attachment));
Expand Down Expand Up @@ -2170,7 +2171,7 @@ rmw_create_service(
z_queryable_options_default(&qable_options);
qable_options.complete = true;
if (z_declare_queryable(
&service_data->qable, session, z_loan(service_data->keyexpr),
session, &service_data->qable, z_loan(service_data->keyexpr),
z_move(callback), &qable_options) != Z_OK)
{
RMW_SET_ERROR_MSG("unable to create zenoh queryable");
Expand All @@ -2191,7 +2192,7 @@ rmw_create_service(
}
});
if (zc_liveliness_declare_token(
&service_data->token, session, z_loan(liveliness_ke),
session, &service_data->token, z_loan(liveliness_ke),
NULL) != Z_OK)
{
RMW_ZENOH_LOG_ERROR_NAMED(
Expand Down Expand Up @@ -2433,8 +2434,9 @@ rmw_send_response(
z_query_reply_options_default(&options);

z_owned_bytes_t attachment;
rmw_zenoh_cpp::create_map_and_set_sequence_num(&attachment, request_header->sequence_number,
request_header->writer_guid);
rmw_zenoh_cpp::create_map_and_set_sequence_num(
&attachment, request_header->sequence_number,
request_header->writer_guid);
options.attachment = z_move(attachment);

z_owned_bytes_t payload;
Expand Down
2 changes: 1 addition & 1 deletion zenoh_c_vendor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ set(ZENOHC_CARGO_FLAGS "--no-default-features$<SEMICOLON>--features=shared-memor
# - https://github.com/eclipse-zenoh/zenoh-c/pull/620 (fix ze_querying_subscriber_get API to query newly discovered publishers)
ament_vendor(zenoh_c_vendor
VCS_URL https://github.com/eclipse-zenoh/zenoh-c.git
VCS_VERSION e270137cbe109032feecf06389b0560e75fc8c84
VCS_VERSION a5232cfa1ccc760b2e89fde3efd522795d0e1dc9
CMAKE_ARGS
"-DZENOHC_CARGO_FLAGS=${ZENOHC_CARGO_FLAGS}"
"-DZENOHC_BUILD_WITH_UNSTABLE_API=TRUE"
Expand Down