Skip to content

Convert all rcl_*_t types to shared pointers - #450

Merged
wjwwood merged 2 commits into
ros2:revert-448-revert-431-issue-349from
clearpathrobotics:issue-349-2
Mar 19, 2018
Merged

wjwwood merged 2 commits into
ros2:revert-448-revert-431-issue-349from
clearpathrobotics:issue-349-2

Conversation

@guillaumeautran

Copy link
Copy Markdown
Contributor

Converts all rcl_*_t types in the memory allocation strategy to shared pointers to prevent crash happening when a subscriber is reset.

Issue: #349

@guillaumeautran

Copy link
Copy Markdown
Contributor Author

FYI: @wjwwood

Comment thread rclcpp/include/rclcpp/service.hpp Outdated
rcl_reset_error();
}
} else {
RCLCPP_FATAL(

@guillaumeautran guillaumeautran Mar 15, 2018 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

changed these to RCLCPP_FATAL (there is no RCLCPP_CRITICAL). Let me know if you would rather have it classified differently.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would expect FATAL to exit the process. I'd use ERROR instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure thing.

@mikaelarguedas mikaelarguedas added the in review Waiting for review (Kanban column) label Mar 15, 2018
Comment thread rclcpp/include/rclcpp/service.hpp Outdated
rcl_reset_error();
}
} else {
RCLCPP_FATAL(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would expect FATAL to exit the process. I'd use ERROR instead.

Comment thread rclcpp/src/rclcpp/client.cpp Outdated
if (handle) {
if (rcl_client_fini(client, handle.get()) != RCL_RET_OK) {
RCLCPP_ERROR(
rclcpp::get_logger(rcl_node_get_name(handle.get())).get_child("rclcpp"),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I may have missed this also on the previous review, but I think you should use rcl_node_get_logger_name here rather than rcl_node_get_name, which will not include the node's namespace.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will do.

Comment thread rclcpp/include/rclcpp/client.hpp Outdated
std::shared_ptr<rcl_node_t> node_handle_;

std::shared_ptr<rcl_client_t> client_handle_;
std::shared_ptr<rcl_node_t> node_handle_;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this order change important? Otherwise I'd ask you to leave it as-is.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We want the client handle to be destructed before the node handle. I agree that relying on implicit class destruction is naive. I'll make it explicit in the ClientBase desctructor.

Comment thread rclcpp/include/rclcpp/service.hpp Outdated
std::weak_ptr<rcl_node_t> weak_node_handle(node_handle_);
// rcl does the static memory allocation here
service_handle_ = std::shared_ptr<rcl_service_t>(
new rcl_service_t, [ = ](rcl_service_t * service)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I let this slide in the last review, but I actually think the implicit copy capture here is dangerous, because it also captures this, and therefore it's too each to accidentally use something from this inside the lambda in the future which will compile and work until the case where you delete the class but something else has a handle to the rcl_service_t (applies to each of the entity types).

I'd feel better about it with explicitly listing what you need to capture by copy or reference, rather than using one of the catch all ones. So in this case it should be just [weak_node_handle].

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No problem. Changing...

Comment thread rclcpp/src/rclcpp/client.cpp Outdated
rcl_ret_t ret =
rcl_service_server_is_available(this->get_rcl_node_handle(), client_handle_.get(), &is_ready);
rcl_service_server_is_available(
this->get_rcl_node_handle(), get_client_handle().get(), &is_ready);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please do not wrap both the right hand side of an assignment as well as the arguments, but if you have to, make sure to indent the arguments again. Also please use this-> with methods of this class.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think I understand what you are asking but if not, let me know.

Converts all rcl_*_t types in the memory allocation strategy to shared pointers to prevent crash happening when a subscriber is reset.

Issue: ros2#349
@wjwwood
wjwwood merged commit e2c1658 into ros2:revert-448-revert-431-issue-349 Mar 19, 2018
@wjwwood wjwwood removed the in review Waiting for review (Kanban column) label Mar 19, 2018
nnmm pushed a commit to ApexAI/rclcpp that referenced this pull request Jul 9, 2022
DensoADAS pushed a commit to DensoADAS/rclcpp that referenced this pull request Aug 5, 2022
* added db directory creation to storage factory

Signed-off-by: Marwan Taher <[email protected]>

* moved db directory creation to rosbag2_cpp

Signed-off-by: Marwan Taher <[email protected]>

* rasing exception if dir already exists

Signed-off-by: Marwan Taher <[email protected]>

* removed dir creation from record.py, added dir creation to sequential_compression_writer and refactored dir creation in sequential_writer

Signed-off-by: Marwan Taher <[email protected]>

* fixed failing tests

Signed-off-by: Marwan Taher <[email protected]>

* fixing review comments

Signed-off-by: Marwan Taher <[email protected]>

* Apply suggestions from code review

Co-authored-by: Karsten Knese <[email protected]>
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.

3 participants