-
Notifications
You must be signed in to change notification settings - Fork 117
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
Node name in user data #182
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,14 +65,23 @@ create_node( | |
} | ||
|
||
// Declare everything before beginning to create things. | ||
::ParticipantListener * listener = nullptr; | ||
Participant * participant = nullptr; | ||
rmw_guard_condition_t * graph_guard_condition = nullptr; | ||
CustomParticipantInfo * node_impl = nullptr; | ||
rmw_node_t * node_handle = nullptr; | ||
ReaderInfo * tnat_1 = nullptr; | ||
WriterInfo * tnat_2 = nullptr; | ||
std::pair<StatefulReader *, StatefulReader *> edp_readers; | ||
|
||
Participant * participant = Domain::createParticipant(participantAttrs); | ||
try { | ||
listener = new ::ParticipantListener(); | ||
} catch (std::bad_alloc &) { | ||
RMW_SET_ERROR_MSG("failed to allocate participant listener"); | ||
goto fail; | ||
} | ||
|
||
participant = Domain::createParticipant(participantAttrs, listener); | ||
if (!participant) { | ||
RMW_SET_ERROR_MSG("create_node() could not create participant"); | ||
return nullptr; | ||
|
@@ -98,6 +107,7 @@ create_node( | |
} | ||
node_handle->implementation_identifier = eprosima_fastrtps_identifier; | ||
node_impl->participant = participant; | ||
node_impl->listener = listener; | ||
node_impl->graph_guard_condition = graph_guard_condition; | ||
node_handle->data = node_impl; | ||
|
||
|
@@ -160,6 +170,7 @@ create_node( | |
"failed to destroy guard condition during error handling") | ||
} | ||
} | ||
rmw_free(listener); | ||
if (participant) { | ||
Domain::removeParticipant(participant); | ||
} | ||
|
@@ -217,7 +228,17 @@ rmw_create_node( | |
Domain::getDefaultParticipantAttributes(participantAttrs); | ||
|
||
participantAttrs.rtps.builtin.domainId = static_cast<uint32_t>(domain_id); | ||
// since the participant name is not part of the DDS spec | ||
participantAttrs.rtps.setName(name); | ||
// the node name is also set in the user_data | ||
size_t name_length = strlen(name); | ||
const char prefix[6] = "name="; | ||
participantAttrs.rtps.userData.resize(name_length + sizeof(prefix)); | ||
memcpy(participantAttrs.rtps.userData.data(), prefix, sizeof(prefix) - 1); | ||
for (size_t i = 0; i < name_length; ++i) { | ||
participantAttrs.rtps.userData[sizeof(prefix) - 1 + i] = name[i]; | ||
} | ||
participantAttrs.rtps.userData[sizeof(prefix) - 1 + name_length] = ';'; | ||
|
||
if (security_options->security_root_path) { | ||
// if security_root_path provided, try to find the key and certificate files | ||
|
@@ -307,10 +328,12 @@ rmw_destroy_node(rmw_node_t * node) | |
result_ret = RMW_RET_ERROR; | ||
} | ||
|
||
delete impl; | ||
|
||
Domain::removeParticipant(participant); | ||
|
||
delete impl->listener; | ||
impl->listener = nullptr; | ||
delete impl; | ||
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. would 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. Since |
||
|
||
return result_ret; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Should this go next to the previous comment line ?
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 don't think so since the previous line sets the name on the participant and only the following lines set it in the user data.
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.
Sorry that was unclear, I meant the other way around:
Does that make sense?
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 think it is fine as it is. Please feel free to update it if you think its clearer.
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.
Currently the first comment makes clear that setting the participant name is not covered by the spec - right when it is setting that attribute.
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.
fair enough, let's leave it as is then