-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Fix shutdown waitgroup panic #35676
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
base: main
Are you sure you want to change the base?
Fix shutdown waitgroup panic #35676
Conversation
|
|
modules/graceful/server.go
Outdated
|
||
// Close all connections outside the lock to avoid deadlock | ||
for _, conn := range connections { | ||
_ = conn.Conn.Close() // Force close the underlying connection |
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.
Not right, you can't close "underlying", you must close the conn itself.
} | ||
app := cmd.NewMainApp(cmd.AppVersion{Version: Version, Extra: formatBuiltWith()}) | ||
_ = cmd.RunMainApp(app, os.Args...) // all errors should have been handled by the RunMainApp | ||
log.GetManager().Close() |
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.
I don't think it is right. Are you sure cli.OsExiter
is always called?
45d862c
to
b70d961
Compare
You can reproduce doesn't mean the fix is right.
I am showing the "DATA-RACE". "listener.Close" and "Accept" are in different threads. Anyway, talk is cheap, I showed you my code. |
b70d961
to
035aa77
Compare
Your change is also wrong. I have told you the root problem and it is not easy to fix. #35551 (comment) |
This PR fixes a panic issue in the WaitGroup that occurs when Gitea is shut down using Ctrl+C.
It ensures that all active connection pointers in the server are properly tracked and forcibly closed when the hammer shutdown is invoked.
The process remains graceful — the normal shutdown sequence runs before the hammer is triggered, and existing connections are given a timeout period to complete gracefully.
This PR also fixes
no logger writer
problem. Now the log close will only be invoked when the command exit.