-
Notifications
You must be signed in to change notification settings - Fork 163
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
router: implement a proper shutdown mechanism #4578
Conversation
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.
Reviewed 3 of 3 files at r1, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @oncilla)
Sorry for being late to this discussion. I wonder if there is still the possibility for a kind of ABA problem here. In the scenario where we have a router This scenario is definitely unlikely, but I think there is still the possibility of a race here. If you agree with this, then I think that a valid fix would be to replace the PS: I wonder if it would make sense to call |
I agree. I don't much see a real use case for sharing the management of a router between multiple threads but it is theoretically possible. Multiple threads could also fight over interfaces during initialization, which is also unlikely to produce sensible results. Note that after a call to Shutdown, the router is committed to terminating, so there's not much incentive in using Shutdown() as a way to allow reconfigurations. As things stand at the moment, the shutdown mechanism only exists so unit tests can terminate the router. I almost did what you described (i.e. more than two states) and then stopped myself...YAGNI. But if that loose end bothers you, you are mot welcome to file a new issue (or re-open yours) and propose such an improvement. It shouldn't add much complexity, so I won't object on those grounds. |
The "running" flag is now accessed as an atomic (so with sequential ordering per the Go memory model). Added a shutdown entry point which cannot race with initialization.
Fixes #4116