1
0
Fork 0
forked from forgejo/forgejo

Refactor graceful manager, fix misused WaitGroup (#29738)

Follow #29629

(cherry picked from commit d08f4360c96e130e0454b76ecef9405f2bd312a1)
This commit is contained in:
coldWater 2024-03-15 18:59:11 +08:00 committed by Earl Warren
parent 1a17c39e00
commit 94c70c7753
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
4 changed files with 55 additions and 51 deletions

View file

@ -233,7 +233,10 @@ func (g *Manager) setStateTransition(old, new state) bool {
// At the moment the total number of servers (numberOfServersToCreate) are pre-defined as a const before global init,
// so this function MUST be called if a server is not used.
func (g *Manager) InformCleanup() {
g.createServerWaitGroup.Done()
g.createServerCond.L.Lock()
defer g.createServerCond.L.Unlock()
g.createdServer++
g.createServerCond.Signal()
}
// Done allows the manager to be viewed as a context.Context, it returns a channel that is closed when the server is finished terminating