Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure OnStart/OnStop hooks can only be called once (#931)
* 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 #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>
- Loading branch information
Showing
2 changed files
with
74 additions
and
20 deletions.
There are no files selected for viewing
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
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