-
Notifications
You must be signed in to change notification settings - Fork 120
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
Ensure rmw_destroy_node() completes despite run-time errors. #458
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,12 +85,34 @@ rmw_destroy_node(rmw_node_t * node) | |
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION); | ||
|
||
rmw_context_t * context = node->context; | ||
rmw_ret_t ret = rmw_fastrtps_shared_cpp::__rmw_destroy_node( | ||
|
||
rmw_ret_t ret = RMW_RET_OK; | ||
rmw_error_state_t error_state; | ||
rmw_ret_t inner_ret = rmw_fastrtps_shared_cpp::__rmw_destroy_node( | ||
eprosima_fastrtps_identifier, node); | ||
if (RMW_RET_OK != ret) { | ||
return ret; | ||
error_state = *rmw_get_error_state(); | ||
ret = inner_ret; | ||
rmw_reset_error(); | ||
} | ||
|
||
inner_ret = rmw_fastrtps_shared_cpp::decrement_context_impl_ref_count(context); | ||
if (RMW_RET_OK != inner_ret) { | ||
if (RMW_RET_OK != ret) { | ||
RMW_SAFE_FWRITE_TO_STDERR(rmw_get_error_string().str); | ||
RMW_SAFE_FWRITE_TO_STDERR(" during '" RCUTILS_STRINGIFY(__function__) "'\n"); | ||
} else { | ||
error_state = *rmw_get_error_state(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there an easy way to combine the two error states should there be multiple failures? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As of today, there isn't. In general, we don't handle errors during error handling and/or finalization very well or at all. I opened an issue about this: ros2/rcutils#269, to have an standard idiom for it. For the moment, this makes sure the first error goes into the error state and any other errors that may follow do not get lost but do not obscure what is assumed to be the root cause of the error. |
||
ret = inner_ret; | ||
} | ||
rmw_reset_error(); | ||
} | ||
|
||
if (RMW_RET_OK != ret) { | ||
rmw_set_error_state(error_state.message, error_state.file, error_state.line_number); | ||
} | ||
return rmw_fastrtps_shared_cpp::decrement_context_impl_ref_count(context); | ||
|
||
return ret; | ||
} | ||
|
||
const rmw_guard_condition_t * | ||
|
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.
You don't want to log the error here as well?
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.
There're no errors before this one, so we can put in the local error state w/o printing.