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
Ensure OnStart/OnStop hooks can only be called once #931
Merged
Conversation
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
It is possible for a user to erroneously call app.Run() then follow up by calling app.Stop(). In such a case, it is possible for the app.Stop() method to be called by two goroutines concurrently, resulting in a race. This adds a state in the App to keep track of whether Stop() has been invoked so that such a race can be prevented. Fix uber-go#930 Internal Ref: GO-1606
Codecov Report
@@ Coverage Diff @@
## master #931 +/- ##
=======================================
Coverage 98.72% 98.72%
=======================================
Files 30 30
Lines 1332 1337 +5
=======================================
+ Hits 1315 1320 +5
Misses 11 11
Partials 6 6
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
sywhang
changed the title
Ensure OnStop hooks can only be called once
Ensure OnStart/OnStop hooks can only be called once
Aug 23, 2022
abhinav
approved these changes
Aug 24, 2022
Co-authored-by: Abhinav Gupta <mail@abhinavg.net>
sywhang
added a commit
to sywhang/fx
that referenced
this pull request
Sep 28, 2022
)" This reverts commit 5566339.
sywhang
added a commit
that referenced
this pull request
Sep 28, 2022
sywhang
added a commit
to sywhang/fx
that referenced
this pull request
Sep 28, 2022
…ber-go#931)" (uber-go#946)" This reverts commit 550fe46.
sywhang
added a commit
to sywhang/fx
that referenced
this pull request
Oct 11, 2022
* Ensure OnStop hooks can only be called once It is possible for a user to erroneously call app.Run() then follow up by calling app.Stop(). In such a case, it is possible for the app.Stop() method to be called by two goroutines concurrently, resulting in a race. This adds a state in the App to keep track of whether Stop() has been invoked so that such a race can be prevented. Fix uber-go#930 Internal Ref: GO-1606 * use sync.Once and also add the check for OnStart hooks * Apply suggestions from code review Co-authored-by: Abhinav Gupta <mail@abhinavg.net> Co-authored-by: Abhinav Gupta <mail@abhinavg.net>
sywhang
added a commit
to sywhang/fx
that referenced
this pull request
Oct 11, 2022
)" (uber-go#946) This reverts commit 5566339.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
It is possible for a user to erroneously call app.Run() then
follow up by calling app.Stop(). In such a case, it is possible
for the app.Stop() method to be called by two goroutines concurrently,
resulting in a race.
This adds a state in the App to keep track of whether Stop() has been
invoked so that such a race can be prevented.
Fix #930
Internal Ref: GO-1606