Skip to content
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

More strict check for topic of all unsubscribe-related operations #87

Closed
qiuzhong opened this issue Mar 29, 2018 · 1 comment
Closed
Labels
fixed verified Issue fixed and verified

Comments

@qiuzhong
Copy link
Collaborator

qiuzhong commented Mar 29, 2018

All the unsubscribe-related operations: unsubscribe and unsubscribe_service should be treated as more strict check, like type checking or whether the topic exists.

Here is the current implementation of unsubscribe operation.

    this._registerOpMap('unsubscribe', (command) => {
      debug(`unsubscribe a topic named ${command.topic}`);
      this._resourceProvider.destroySubscription(command.topic);
    });

This is simply hands the control to the resourceProvide during unsubscribe and it only handles the normal branch: when this topic exists.

  destroySubscription(topicName, bridgeId) {
    if (this._subscripions.has(topicName)) {
      let handle = this._subscripions.get(topicName);
      if (handle.hasCallbackForId(bridgeId)) {
        handle.removeCallback(bridgeId);
        handle.release();
        if (handle.count === 0) {
          this._subscripions.delete(topicName);
        }
      }
    }
  }

As a result, invalid type of topic brings a none level response, which means the unsubscribe succeed. This is wrong and confusing.

What we expected:

  • Invalid topic type: a error returned.
  • Valid topic type but not existed, a warning returned.

For the unsubscribe_service operation, same proposal had been issued in the comments of PR #82.

@qiuzhong qiuzhong changed the title More strict check for all unsubscribe-related operations More strict check for topic of all unsubscribe-related operations Mar 29, 2018
minggangw pushed a commit to minggangw/ros2bridge_suite-experiment that referenced this issue Apr 8, 2018
Before this patch, when the bridge received the operation code 'unsubscribe',
it will not validate the topic name(e.g. validity of the topic or if it existed).

This patch implements that when receiving the 'unsubscribe' op, the bridge will
valide the name of the topic first. If the name itself is invalid, an error will
return. If the topic name doesn't exist, a warning will return.

Fix RobotWebTools#87
minggangw pushed a commit that referenced this issue Apr 8, 2018
Before this patch, when the bridge received the operation code 'unsubscribe',
it will not validate the topic name(e.g. validity of the topic or if it existed).

This patch implements that when receiving the 'unsubscribe' op, the bridge will
valide the name of the topic first. If the name itself is invalid, an error will
return. If the topic name doesn't exist, a warning will return.

Fix #87
qiuzhong added a commit to qiuzhong/ros2-web-bridge that referenced this issue Apr 8, 2018
Since issue RobotWebTools#87 is fixed and the test cases commented in `test-unsubscribe.js`
can pass and we uncomment it.
@qiuzhong
Copy link
Collaborator Author

qiuzhong commented Apr 8, 2018

Verified as PR #89 comments.

@qiuzhong qiuzhong added verified Issue fixed and verified fixed labels Apr 8, 2018
minggangw pushed a commit that referenced this issue Apr 8, 2018
Since issue #87 is fixed and the test cases commented in `test-unsubscribe.js`
can pass and we uncomment it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed verified Issue fixed and verified
Projects
None yet
Development

No branches or pull requests

1 participant