This repository was archived by the owner on May 31, 2025. It is now read-only.
fix getNumPublishers() to only count fully connected#2107
Merged
jacobperron merged 1 commit intoros:noetic-develfrom Dec 28, 2020
Merged
Conversation
There is code which uses getNumPublishers() being positive as a guarantee that a call to the remote publisher's publish() is guaranteed to send a message to the subscriber. However, because connections which have not yet received their header are counted, this is not true. One such user of getNumPublishers() is actionlib. It relies on getNumPublishers() only returning postive when a publish on the result topic would succeed. Fix this by only counting connections with received headers. If we have received the header, we know the remote publisher is tracking a connection back to us and has accepted the connection and that a call to publish() on its end will send the message. Note that this issue is only relevant for the TCP transport, as the UDP transport and intraprocess link have already setup their header by the time they are added to the publication links. Since all publisher link types update the header, including the caller ID, counting those with caller IDs set to non-empty is sufficient to solve the issue.
873f275 to
b577505
Compare
fujitatomoya
approved these changes
Dec 17, 2020
Contributor
fujitatomoya
left a comment
There was a problem hiding this comment.
this makes sense to me. only happens with TCPROS but there is a possibility that header is not registered via Connection::onHeaderLengthRead. keeping the behavior consistent for Subscription::getNumPublishers makes sense.
jacobperron
approved these changes
Dec 28, 2020
Contributor
jacobperron
left a comment
There was a problem hiding this comment.
LGTM, thanks for the fix!
jacobperron
pushed a commit
that referenced
this pull request
Apr 6, 2021
There is code which uses getNumPublishers() being positive as a guarantee that a call to the remote publisher's publish() is guaranteed to send a message to the subscriber. However, because connections which have not yet received their header are counted, this is not true. One such user of getNumPublishers() is actionlib. It relies on getNumPublishers() only returning postive when a publish on the result topic would succeed. Fix this by only counting connections with received headers. If we have received the header, we know the remote publisher is tracking a connection back to us and has accepted the connection and that a call to publish() on its end will send the message. Note that this issue is only relevant for the TCP transport, as the UDP transport and intraprocess link have already setup their header by the time they are added to the publication links. Since all publisher link types update the header, including the caller ID, counting those with caller IDs set to non-empty is sufficient to solve the issue.
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 is code which uses getNumPublishers() being positive as a
guarantee that a call to the remote publisher's publish() is
guaranteed to send a message to the subscriber. However, because
connections which have not yet received their header are counted,
this is not true. One such user of getNumPublishers() is actionlib.
It relies on getNumPublishers() only returning postive when a publish
on the result topic would succeed.
Fix this by only counting connections with received headers. If we
have received the header, we know the remote publisher is tracking a
connection back to us and has accepted the connection and that a
call to publish() on its end will send the message.
Note that this issue is only relevant for the TCP transport, as the
UDP transport and intraprocess link have already setup their header
by the time they are added to the publication links. Since all
publisher link types update the header, including the caller ID,
counting those with caller IDs set to non-empty is sufficient to
solve the issue.