-
Notifications
You must be signed in to change notification settings - Fork 283
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
onStop executed many times #930
Labels
Comments
Root-cause: the signal handler that gets registered on SIGINT races with the Stop() method being invoked by the user code. |
sywhang
added a commit
to sywhang/fx
that referenced
this issue
Aug 23, 2022
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
sywhang
added a commit
that referenced
this issue
Aug 24, 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 #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 issue
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>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Discussed in #929
Originally posted by coolyrat August 22, 2022
When I give the stop signal, the log
And I am expected to be
Is there anything I'm doing wrong?
The text was updated successfully, but these errors were encountered: