- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 6.2k
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
Fix shutdown waitgroup panic #35676
Conversation
| 
 | 
| 
 
 | 
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) | 
| srv.lock.Unlock() | ||
| srv.connEmptyCond.Broadcast() | 
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’m not familiar with the sync functions, so this is just a question.
Should Broadcast be called before Unlock?
In the code above, Broadcast is always called before Unlock.
I asked AI about it, and it said it isn’t safe, so I left this comment.
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.
Maybe AI didn't read the Golang doc: https://pkg.go.dev/sync#Cond.Broadcast
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 think @yp05327 means it’s inconsistent because, on line 209, the Broadcast function is called before the lock is released.
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 asked AI about it, and it said it isn’t safe, so I left this comment.
I think @yp05327 means it’s inconsistent because ....
He means it isn’t safe, not inconsistent
Does "not safe" mean "inconsistent" in your mind?
* giteaofficial/main: [skip ci] Updated translations via Crowdin Revert go-gitea#18491, fix oauth2 client link account (go-gitea#35745) Upgrade go mail to 0.7.2 (go-gitea#35748) [skip ci] Updated translations via Crowdin Support actions and reusable workflows from private repos (go-gitea#32562) Use git model to detect whether branch exist instead of gitrepo method (go-gitea#35459) Fix shutdown waitgroup panic (go-gitea#35676) Intorduce "config edit-ini" sub command to help maintaining INI config file (go-gitea#35735) Improve online runner check (go-gitea#35722) Make "update file" API can create a new file when SHA is not set (go-gitea#35738) Fix review request webhook bug (go-gitea#35339) (go-gitea#35723) Misc tool tweaks (go-gitea#35734) Update dependencies (go-gitea#35733) Make external iframe render work (go-gitea#35730) Remove mermaid margin workaround (go-gitea#35732) # Conflicts: # models/user/user.go
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 writerproblem. Now the log close will only be invoked when the command exit.