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

Another fix for ClientData. #336

Merged
merged 2 commits into from
Dec 11, 2024
Merged

Another fix for ClientData. #336

merged 2 commits into from
Dec 11, 2024

Conversation

clalancette
Copy link
Collaborator

In this fix, what we do is to manually allocate a struct that wraps the ClientData. Inside of that struct, we take a shared_ptr reference to ClientData. And then in client_data_drop, we manually delete the struct.

This ensures that the ClientData object is not destroyed while there are still requests in-flight. This also allows us to get rid of the tricky tracking of the num_in_flight; we don't need it anymore, and the rmw_node_data_t can just drop the reference directly.

Finally, I'll note that this is basically equivalent to do a lambda capture when zenoh-cpp. Still, I think this is worthwhile getting in before #327 since it fixes UB and it is relatively easy to understand.

Signed-off-by: Chris Lalancette <[email protected]>
@clalancette clalancette requested a review from Yadunund December 10, 2024 20:25
Signed-off-by: Yadunund <[email protected]>
Copy link
Member

@Yadunund Yadunund left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a much cleaner approach with the existing implementation!

@Yadunund Yadunund merged commit ca5058c into rolling Dec 11, 2024
6 checks passed
@Yadunund Yadunund deleted the clalancette/client-data-fix branch December 11, 2024 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants