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

Fix bug on the disorder of calling shutdown callback #2097

Conversation

Barry-Xu-2018
Copy link
Collaborator

Address #2096

Signed-off-by: Barry Xu barry.xu@sony.com

Signed-off-by: Barry Xu <barry.xu@sony.com>
Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

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

One very minor thing pointed out inline. Otherwise looks good with green CI.

rclcpp/test/rclcpp/test_context.cpp Outdated Show resolved Hide resolved
Copy link
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

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

lgtm! @Barry-Xu-2018 thanks for quick response.

@fujitatomoya
Copy link
Collaborator

@clalancette @alsora thanks for the review, btw can we backport this to humble?

@fujitatomoya
Copy link
Collaborator

fujitatomoya commented Feb 2, 2023

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@clalancette
Copy link
Contributor

@clalancette @alsora thanks for the review, btw can we backport this to humble?

Hm. So unfortunately, this breaks ABI because of the change of type from std::unordered_set to std::vector. So this would not generally be eligible for backporting. We'd have to consider another non-ABI breaking way to backport this, or explicitly make an exception here.

Signed-off-by: Barry Xu <barry.xu@sony.com>
@fujitatomoya
Copy link
Collaborator

  • Windows Build Status

@fujitatomoya
Copy link
Collaborator

@clalancette if the backport is hard requirement, we would probably consider other approach. I believe that breaking ABI/API policy would be much bigger problem.

@Barry-Xu-2018
Copy link
Collaborator Author

@clalancette @fujitatomoya

In order to keep ABI compatible, we cannot add new variable (except static variable) into class Context.
Maybe use global variable as one solution, but it will make code ugly.

struct ShutdownCallback {
  std::vector<weak_ptr> pre_callback;
  std::vector<weak_ptr> on_callback;
};

static std:map<Context*, ShutdownCallback> g_shutdownCallback;
static mutex s_shutdownCallback_mutex;

Change code on adding/removing/call shutdown callback to use this global variable.

Now I not find better approach

@clalancette
Copy link
Contributor

I'm going to go ahead and merge this one in, since it is an obvious improvement for Rolling. We can consider fixing Humble (either the documentation or with an ABI-compatible fix) separately.

@clalancette clalancette merged commit 1fd5a96 into ros2:rolling Feb 6, 2023
alsora pushed a commit to irobot-ros/rclcpp that referenced this pull request Apr 29, 2023
* Fix bug on the disorder of calling shutdown callback

Signed-off-by: Barry Xu <barry.xu@sony.com>
alsora pushed a commit to irobot-ros/rclcpp that referenced this pull request Apr 29, 2023
* Fix bug on the disorder of calling shutdown callback

Signed-off-by: Barry Xu <barry.xu@sony.com>
alsora pushed a commit to irobot-ros/rclcpp that referenced this pull request May 3, 2023
* Fix bug on the disorder of calling shutdown callback

Signed-off-by: Barry Xu <barry.xu@sony.com>
alsora pushed a commit to irobot-ros/rclcpp that referenced this pull request May 3, 2023
* Fix bug on the disorder of calling shutdown callback

Signed-off-by: Barry Xu <barry.xu@sony.com>
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.

None yet

4 participants