-
Notifications
You must be signed in to change notification settings - Fork 43
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
Conversation
61dafb0
to
7bd5073
Compare
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.
fix conflicts
7bd5073
to
b09fa97
Compare
@ahcorde could you help check if the expected tests are passing here? |
rmw_zenoh/yadu/raii-service
|
Because of #298, this now needs a rebase and conflicts resolved. Once that is done, I'll do another review pass over it. |
@clalancette i've resolved the conflicts! |
type_support, | ||
qos_profile)) | ||
{ | ||
// Error already handled. | ||
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.
If a step below fails, do we need to remove this client from the node? In other words, do we need a rcpputils::scope_exit
block here?
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.
Ah nope! The shared_ptr we created within create_client_data
will go out of scope and the destructor will clean everything up. The free_rmw_client
block will take care of deallocating the rmw_client_t
object.
if (client_data == nullptr) { | ||
RMW_SET_ERROR_MSG_WITH_FORMAT_STRING( | ||
"Unable to retreive client_data from client for service %s", client->service_name); | ||
return RMW_RET_INVALID_ARGUMENT; | ||
} | ||
|
||
std::string service_type = client_data->request_type_support->get_name(); | ||
size_t suffix_substring_position = service_type.find("Request_"); |
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 notice that we are no longer checking whether the service_type has Request_
in it. Do we need to add that back in?
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.
So this check was moved inside ClientData::make()
but there was typo there anyways which I have fixed 4c9b106. It would not have caused any problems since the substring we extract will be the same but now it's semantically correct.
51f2917
to
37e2e03
Compare
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.
Overall, I like the new direction here. I have some specific concerns on some of the data handling inline.
nav2 demo crashes when the following steps are performed
|
It seems like 082e64c introduced this behavior as I can't reproduce the crash if I drop that commit. |
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.
conflicts
0630d06
to
6234eb2
Compare
I've now rebased it onto the latest. |
Signed-off-by: Yadunund <[email protected]>
Signed-off-by: Yadunund <[email protected]>
Signed-off-by: Yadunund <[email protected]>
Signed-off-by: Yadunund <[email protected]>
Signed-off-by: Yadunund <[email protected]>
* Additional fixes for yadu/raii-client. Signed-off-by: Chris Lalancette <[email protected]> * Apply suggestions from code review Co-authored-by: yadunund <[email protected]> Signed-off-by: Chris Lalancette <[email protected]> * Fixups. Signed-off-by: Chris Lalancette <[email protected]> --------- Signed-off-by: Chris Lalancette <[email protected]> Co-authored-by: yadunund <[email protected]>
Signed-off-by: Yadunund <[email protected]>
This just makes it more consistent with the rest of the APIs. Signed-off-by: Chris Lalancette <[email protected]>
Signed-off-by: Yadunund <[email protected]>
We basically use the pointer as a key to lookup the shared_ptr, and then always use the shared_ptr. That ensures that even if the pointer was dropped from the node while the client callback is operating, it will still be valid and won't be destroyed until that method returns. Signed-off-by: Chris Lalancette <[email protected]>
c4887d7
to
821f4e9
Compare
All right, I've just rebased this and also pushed another commit to vastly simplify our handling of in-flight data. I think this should work a lot more reliably now. With that, I'm going to approve and merge this. Thanks for the long slog on this one. |
Make access to
ClientData
thread-safe.I've not fully tested this PR yet but I knowcolcon test --event-handlers console_direct+ --packages-select rclcpp_action --ctest-args -R test_server
fails. It has to do with how i'm handling cases where the client is shutdown when there are still queries in flight.