summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-03-06 19:00:21 +0800
committerGitHub <noreply@github.com>2024-03-06 11:00:21 +0000
commit2f1eb619bc19a9b172062ba17789356bbdaa259d (patch)
tree19bbd7f95658bd10089d255728d6dcf78321e88d /modules
parent9db426ad8c7122633fa3e31a427fd1e65ddad334 (diff)
downloadgitea-2f1eb619bc19a9b172062ba17789356bbdaa259d.tar.gz
gitea-2f1eb619bc19a9b172062ba17789356bbdaa259d.zip
Avoid unexpected panic in graceful manager (#29629) (#29630)
Backport #29629
Diffstat (limited to 'modules')
-rw-r--r--modules/graceful/manager_unix.go10
-rw-r--r--modules/graceful/manager_windows.go10
2 files changed, 18 insertions, 2 deletions
diff --git a/modules/graceful/manager_unix.go b/modules/graceful/manager_unix.go
index b1fd6da76d..67c97a6e7e 100644
--- a/modules/graceful/manager_unix.go
+++ b/modules/graceful/manager_unix.go
@@ -118,7 +118,15 @@ func (g *Manager) start(ctx context.Context) {
defer close(startupDone)
// Wait till we're done getting all of the listeners and then close
// the unused ones
- g.createServerWaitGroup.Wait()
+ func() {
+ // FIXME: there is a fundamental design problem of the "manager" and the "wait group".
+ // If nothing has started, the "Wait" just panics: sync: WaitGroup is reused before previous Wait has returned
+ // There is no clear solution besides a complete rewriting of the "manager"
+ defer func() {
+ _ = recover()
+ }()
+ g.createServerWaitGroup.Wait()
+ }()
// Ignore the error here there's not much we can do with it
// They're logged in the CloseProvidedListeners function
_ = CloseProvidedListeners()
diff --git a/modules/graceful/manager_windows.go b/modules/graceful/manager_windows.go
index f676f86d04..6bcae9f747 100644
--- a/modules/graceful/manager_windows.go
+++ b/modules/graceful/manager_windows.go
@@ -227,7 +227,15 @@ func (g *Manager) awaitServer(limit time.Duration) bool {
c := make(chan struct{})
go func() {
defer close(c)
- g.createServerWaitGroup.Wait()
+ func() {
+ // FIXME: there is a fundamental design problem of the "manager" and the "wait group".
+ // If nothing has started, the "Wait" just panics: sync: WaitGroup is reused before previous Wait has returned
+ // There is no clear solution besides a complete rewriting of the "manager"
+ defer func() {
+ _ = recover()
+ }()
+ g.createServerWaitGroup.Wait()
+ }()
}()
if limit > 0 {
select {