-
Notifications
You must be signed in to change notification settings - Fork 36
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
Zenoh 1.0.0 Porting #276
base: rolling
Are you sure you want to change the base?
Zenoh 1.0.0 Porting #276
Conversation
Signed-off-by: Luca Cominardi <[email protected]>
Signed-off-by: Luca Cominardi <[email protected]>
Signed-off-by: Luca Cominardi <[email protected]>
chore: checkout dev/1.0.0
…n the zenoh_c_vendor
#ifndef DETAIL__SHM_CONTEXT_HPP_ | ||
#define DETAIL__SHM_CONTEXT_HPP_ | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#include <cstddef>
namespace rmw_zenoh_cpp | ||
{ | ||
///============================================================================= | ||
#ifdef RMW_ZENOH_BUILD_WITH_SHARED_MEMORY |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file is not included in the CMakeLists.txt
#ifdef RMW_ZENOH_BUILD_WITH_SHARED_MEMORY | ||
struct ShmContext | ||
{ | ||
z_owned_shm_provider_t shm_provider; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing header
#ifdef RMW_ZENOH_BUILD_WITH_SHARED_MEMORY | ||
ShmContext::~ShmContext() | ||
{ | ||
z_drop(z_move(shm_provider)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm getting a segfault here, double free
Not sure what the status of the abovementioned issue by @ahcorde is but I am getting the following with the latest commit: |
@alireza-moayyedi Sorry for the inconvenience. There are some errors with the latest commit. Would you mind using the previous one? I've tested with this one. We will fix that ASAP. |
Hi @alireza-moayyedi! It has been fixed 😃 |
hey @evshary , Yes indeed I switched to ZettaScaleLabs@28d917e for the time being. And of course, no apologies required. This is what open source is for and I am more than grateful for your contributions ;-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've done a first review pass (for me), and left some comments. Once this is rebased onto the latest and my comments are addressed, I'll do another review pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just remove this file from the pull request for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 9f78ca4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file is still present...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides what I left inline, I'm did a head-to-head comparison between rolling
and the dev/1.0.0
branch. Some of this matches what is in #286 (comment) , though some of it is different.
package | test | rolling branch (3d771c8) |
dev/1.0.0 branch (9f78ca4) |
note |
---|---|---|---|---|
rcl | test_guard_condition | ✔️ | ❌ | particularly under load |
rcl_action | test_action_server | ✔️ | ❌ | |
rclcpp | test_client_common | ✔️ | ❌ | |
rclcpp | test_publisher | ❌ | ❌ | |
rclcpp_action | test_server | ✔️ | ❌ | |
rclcpp_lifecycle | test_lifecycle_service_client | ❌ | ✔️ | flaky; I was only able to make this fail once |
test_rclcpp | test_client_scope_cpp | ✔️ | ❌ | |
test_rclcpp | test_node_name | ✔️ | ❌ | |
test_rclcpp | test_n_nodes | ✔️ | ❌ | |
test_rclcpp | gtest_spin | ❌ | ✔️ | |
test_communication | test_publisher_subscriber_rclcpp_rclpy | ✔️ | ❌ | |
test_communication | test_publisher_subscriber_rclcpp | ❌ | ❌ | |
test_communication | test_requester_replier | ✔️ | ❌ | |
test_quality_of_service | test_deadline | ❌ | ❌ | |
test_quality_of_service | test_liveliness | ❌ | ❌ | |
test_quality_of_service | test_best_available | ❌ | ❌ | |
rclpy | test_action_client | ❌ | ❌ | |
rclpy | test_client | ✔️ | ❌ |
Total failures: rolling
8, dev/1.0.0
15
The failure on test_client_common can be related to this issue ros2/rclcpp#2680. |
This reverts commit 2e3ad43.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-reviewed 75% of the changes and provided some feedback. My primary concern is the introduction of registering a function with the atexit
signal handler. As explained inline, there is still a problem of the static variable being invalidated and 'm confused why we need it with dev/1.0.0 when we do not need it rolling.
Secondly, I think the diff in the PR is way larger than it needs to be. Imo the changes only need reflect changes in the zenoh-c API but there are changes in rmw_zenoh.cpp wrt to checking if entities are valid, and various cleanups to headers.
My recommendation is to take all the changes that remove cleanup headers and target a PR to the current rolling
branch. And save other changes unrelated to breaking zenoh-c API to a future PR.
@@ -68,6 +68,9 @@ int main(int argc, char ** argv) | |||
return 1; | |||
} | |||
|
|||
// Enable the zenoh built-in logger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit
// Enable the zenoh built-in logger | |
// Enable the zenoh built-in logger. |
@@ -361,28 +351,21 @@ rmw_ret_t ClientData::take_response( | |||
} | |||
|
|||
// Fill in the request_header | |||
request_header->request_id.sequence_number = | |||
rmw_zenoh_cpp::get_int64_from_attachment(&sample->attachment, "sequence_number"); | |||
rmw_zenoh_cpp::attachment_data_t attachment(z_sample_attachment(sample)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This API feels awkward and requires you to define the move constructor. Why not just pass const z_loaned_sample_t *
and construct the z_sample_attachment
internally?
if (zc_liveliness_token_check(&token_)) { | ||
zc_liveliness_undeclare_token(z_move(token_)); | ||
} | ||
if (z_check(z_loan(keyexpr_))) { | ||
z_drop(z_move(keyexpr_)); | ||
} | ||
zc_liveliness_undeclare_token(z_move(token_)); | ||
|
||
z_drop(z_move(keyexpr_)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We previously needed this check since it was possible for token_
and keyexpr_
to be uninitialized when shutdown is called within ClientData::make
. Do these functions now check whether the tokens are valid before dropping?
// The variable is used to identify whether the process is trying to exit or not. | ||
// The atexit function we registered will set the flag and prevent us from closing | ||
// Zenoh Session. Zenoh API can't be used in atexit function, because Tokio context | ||
// is already destroyed. It will cause panic if we do so. | ||
static bool is_exiting = false; | ||
void update_is_exiting() | ||
{ | ||
is_exiting = true; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this logic with 1.0.0 only? How do we ensure two or more threads do not access is_exiting
concurrently? Moreover, when the program terminates, static ordering is unknown so there is no guarantee that is_exiting
is valid. That's one of the reasons we redid the way we track ClientData in #310
cc @clalancette
// This global mapping of raw Data pointers to Data shared pointers allows graph_sub_data_handler() | ||
// to lookup the pointer, and gain a reference to a shared_ptr if it exists. | ||
// This guarantees that the Data object will not be destroyed while we are using it. | ||
static std::mutex data_to_data_shared_ptr_map_mutex; | ||
static std::unordered_map<rmw_context_impl_s::Data *, | ||
std::shared_ptr<rmw_context_impl_s::Data>> data_to_data_shared_ptr_map; | ||
|
||
static void graph_sub_data_handler(const z_sample_t * sample, void * data); | ||
static void graph_sub_data_handler(z_loaned_sample_t * sample, void * data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static void graph_sub_data_handler(z_loaned_sample_t * sample, void * data); | |
static void graph_sub_data_handler(const z_loaned_sample_t * sample, void * data); |
// TODO(yuyuan): SHM, make this configurable | ||
#define SHM_BUF_OK_SIZE 2621440 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unused so please remove.
// TODO(yuyuan): SHM, make this configurable | |
#define SHM_BUF_OK_SIZE 2621440 |
if (!context_impl->session_is_valid()) { | ||
RMW_SET_ERROR_MSG("zenoh session is invalid"); | ||
return nullptr; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove this?
/// Finalize a given publisher handle, reclaim the resources, and deallocate the | ||
/// publisher handle. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Undo unnecessary change.
if (!pub_data->liveliness_is_valid()) { | ||
return RMW_RET_ERROR; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove this?
if (!context_impl->session_is_valid()) { | ||
RMW_SET_ERROR_MSG("zenoh session is invalid"); | ||
return nullptr; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, why remove this here and in other functions below?
Notes
z_view_keyexpr_t
ratherz_owned_keyexpr_t
if possible. This keeps the reference only and doesn't need to be dropped.z_check
is now internal. We check zenoh entities' health by the creation functions' return.