diff options
author | zeripath <art27@cantab.net> | 2020-04-27 01:01:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-26 21:01:06 -0300 |
commit | 0e799c26ba322e8e1dd1e5acd1367341c0452987 (patch) | |
tree | 4fef486d5db4e7463563bf3ba327bd9f906ba11b /modules/graceful | |
parent | 9f959ac0641821148e46d0899b74cc714c858879 (diff) | |
download | gitea-0e799c26ba322e8e1dd1e5acd1367341c0452987.tar.gz gitea-0e799c26ba322e8e1dd1e5acd1367341c0452987.zip |
Prevent panic during wrappedConn close at hammertime (#11219)
* Prevent panic during wrappedConn close at hammertime
Signed-off-by: Andrew Thornton <art27@cantab.net>
* Update modules/graceful/server.go
* Fix extraneous debug in goldmark.go
Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/graceful')
-rw-r--r-- | modules/graceful/server.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/modules/graceful/server.go b/modules/graceful/server.go index 09be933999..4d0d8677f0 100644 --- a/modules/graceful/server.go +++ b/modules/graceful/server.go @@ -250,6 +250,17 @@ type wrappedConn struct { func (w wrappedConn) Close() error { if atomic.CompareAndSwapInt32(w.closed, 0, 1) { + defer func() { + if err := recover(); err != nil { + select { + case <-GetManager().IsHammer(): + // Likely deadlocked request released at hammertime + log.Warn("Panic during connection close! %v. Likely there has been a deadlocked request which has been released by forced shutdown.", err) + default: + log.Error("Panic during connection close! %v", err) + } + } + }() w.server.wg.Done() } return w.Conn.Close() |