Skip to content

Commit

Permalink
Check for correct context shutdown (#486)
Browse files Browse the repository at this point in the history
Signed-off-by: Ignacio Montesino <[email protected]>
  • Loading branch information
Ignacio Montesino Valle authored Dec 3, 2020
1 parent 89f5bc9 commit 20b5851
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions rmw_fastrtps_cpp/src/rmw_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ rmw_context_fini(rmw_context_t * context)
RCUTILS_SET_ERROR_MSG("context has not been shutdown");
return RMW_RET_INVALID_ARGUMENT;
}
if (context->impl->count > 0) {
RMW_SET_ERROR_MSG("Finalizing a context with active nodes");
return RMW_RET_ERROR;
}
rmw_ret_t ret = rmw_init_options_fini(&context->options);
delete context->impl;
*context = rmw_get_zero_initialized_context();
Expand Down
4 changes: 4 additions & 0 deletions rmw_fastrtps_dynamic_cpp/src/rmw_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ rmw_context_fini(rmw_context_t * context)
RCUTILS_SET_ERROR_MSG("context has not been shutdown");
return RMW_RET_INVALID_ARGUMENT;
}
if (context->impl->count > 0) {
RMW_SET_ERROR_MSG("Finalizing a context with active nodes");
return RMW_RET_ERROR;
}
rmw_ret_t ret = rmw_init_options_fini(&context->options);
delete context->impl;
*context = rmw_get_zero_initialized_context();
Expand Down

0 comments on commit 20b5851

Please sign in to comment.