Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

implement avoid_ros_namespace_conventions QoS option #227

Merged
merged 4 commits into from
Jun 8, 2017

Conversation

wjwwood
Copy link
Member

@wjwwood wjwwood commented May 31, 2017

This implements the avoid_ros_namespace_conventions QoS option. @Karsten1987 I also refactored this to share code between the pub-sub and again between service-client. It could be deduplicated more, but I think this is incrementally better. I also switched to using rcutils_format_string to address one of your TODO's. Please have a look at those changes carefully when reviewing (lots of copy-paste going on, could be a mistake).

Connects to ros2/rmw#106

@wjwwood wjwwood added the in progress Actively being worked on (Kanban column) label May 31, 2017
@wjwwood wjwwood self-assigned this May 31, 2017
Copy link
Member

@dhood dhood left a comment

Choose a reason for hiding this comment

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

couple of things I noticed while looking over the copy-paste content

bool avoid_ros_namespace_conventions,
char ** request_partition_str,
char ** response_partition_str,
char ** service_str)
Copy link
Member

Choose a reason for hiding this comment

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

the arguments here are not in the same order as __process_topic_name (which has the partition string last): is there a reason for this? If not, consistency would be better to prevent accidental misuse in the future (e.g. when refactoring)

allocator,
"%s/%s", ros_service_response_prefix, name_tokens.data[0]);
if (!response_concat_str) {
allocator.deallocate(request_concat_str, allocator.state);
Copy link
Member

Choose a reason for hiding this comment

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

should this be removed? (it's not in the equivalent block for request_concat_str or concat_str)

Copy link
Member Author

Choose a reason for hiding this comment

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

No, the request_concat_str points to allocated memory at this point. If the deallocate did not happen, then it would be leaked here. There is nothing that needs to be deallocated in either of the other two cases, request_concat_str or concat_str.

Copy link
Member

Choose a reason for hiding this comment

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

yep, thanks. I read it as deallocating response_concat_str.

Copy link
Contributor

@Karsten1987 Karsten1987 left a comment

Choose a reason for hiding this comment

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

lgtm with running CI

I would interested in to see what's happening with setting the ros_prefix to an empty string. I am almost certain that this will work. If so, that would slightly ease the functions by getting rid of the if-case and the boolean parameter to skip the prefix.

@@ -214,6 +213,57 @@ rmw_destroy_node(rmw_node_t * node)
return destroy_node(rti_connext_identifier, node);
}

bool
__process_topic_name(
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick, but I think this file uses only one underscore for "non-public" methods.

// Connext will call deallocate on this, passing ownership to connext
*topic_str = DDS_String_dup(name_tokens.data[1]);
} else {
RMW_SET_ERROR_MSG("Illformated topic name")
Copy link
Contributor

Choose a reason for hiding this comment

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

That might be my incorrect english :)

char ** partition_str)
{
bool success = true;
rcutils_string_array_t name_tokens;
Copy link
Contributor

Choose a reason for hiding this comment

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

I should have default initialized that data structure as done in the service partitions.

@wjwwood wjwwood added enhancement New feature or request in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels Jun 7, 2017
@wjwwood wjwwood merged commit 69bc3e6 into master Jun 8, 2017
@wjwwood wjwwood removed the in review Waiting for review (Kanban column) label Jun 8, 2017
@wjwwood wjwwood deleted the avoid_ros_namespace_conventions_qos branch June 8, 2017 23:40
if (!_process_topic_name(
topic_name,
qos_profile->avoid_ros_namespace_conventions,
&topic_str,
Copy link
Member

Choose a reason for hiding this comment

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

@wjwwood When is the allocated memory of this variable being freed? Same for partition_str next line.

Copy link
Member Author

Choose a reason for hiding this comment

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

Connext takes ownership of it according to this comment: 69bc3e6#diff-becdf01440f1757df19f4775b534e066R251

I believe if you free it then connext later does and you get a double free.

Copy link
Member

Choose a reason for hiding this comment

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

Currently it shows up as being leaked in valgrind with the demo_nodes_cpp talker / listener.

Copy link
Member Author

Choose a reason for hiding this comment

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

You can try freeing it, but I'm pretty sure we were getting a double free before.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, this is the wrong pull request to ask on I think because it was only moved into a function in this pr. The removed code already had this ownership comment in place.

Copy link
Member

Choose a reason for hiding this comment

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

for reference, seems related to https://github.com/ros2/rcl/pull/161/files, maybe doing one will impact the other

Copy link
Member

Choose a reason for hiding this comment

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

for reference, seems related to https://github.com/ros2/rcl/pull/161/files, maybe doing one will impact the other

Those are not related. topic_str is a local variable within rmw_connext_cpp.

Copy link
Member

Choose a reason for hiding this comment

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

@ros2 ros2 deleted a comment from dirk-thomas Aug 31, 2017
@dirk-thomas dirk-thomas mentioned this pull request Aug 31, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants