Skip to content

Commit 57a4e35

Browse files
committed
fix
1 parent 9db426a commit 57a4e35

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

modules/graceful/manager_unix.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,15 @@ func (g *Manager) start(ctx context.Context) {
118118
defer close(startupDone)
119119
// Wait till we're done getting all of the listeners and then close
120120
// the unused ones
121-
g.createServerWaitGroup.Wait()
121+
func() {
122+
// FIXME: there is a fundamental design problem of the "manager" and the "wait group".
123+
// If nothing has started, the "Wait" just panics: sync: WaitGroup is reused before previous Wait has returned
124+
// There is no clear solution besides a complete rewriting of the "manager"
125+
defer func() {
126+
_ = recover()
127+
}()
128+
g.createServerWaitGroup.Wait()
129+
}()
122130
// Ignore the error here there's not much we can do with it
123131
// They're logged in the CloseProvidedListeners function
124132
_ = CloseProvidedListeners()

modules/graceful/manager_windows.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,15 @@ func (g *Manager) awaitServer(limit time.Duration) bool {
227227
c := make(chan struct{})
228228
go func() {
229229
defer close(c)
230-
g.createServerWaitGroup.Wait()
230+
func() {
231+
// FIXME: there is a fundamental design problem of the "manager" and the "wait group".
232+
// If nothing has started, the "Wait" just panics: sync: WaitGroup is reused before previous Wait has returned
233+
// There is no clear solution besides a complete rewriting of the "manager"
234+
defer func() {
235+
_ = recover()
236+
}()
237+
g.createServerWaitGroup.Wait()
238+
}()
231239
}()
232240
if limit > 0 {
233241
select {

0 commit comments

Comments
 (0)