mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-10 12:49:52 +01:00
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>
This commit is contained in:
parent
9f959ac064
commit
0e799c26ba
2 changed files with 11 additions and 1 deletions
|
@ -250,6 +250,17 @@ type wrappedConn struct {
|
||||||
|
|
||||||
func (w wrappedConn) Close() error {
|
func (w wrappedConn) Close() error {
|
||||||
if atomic.CompareAndSwapInt32(w.closed, 0, 1) {
|
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()
|
w.server.wg.Done()
|
||||||
}
|
}
|
||||||
return w.Conn.Close()
|
return w.Conn.Close()
|
||||||
|
|
|
@ -328,7 +328,6 @@ func (r *HTMLRenderer) renderIcon(w util.BufWriter, source []byte, node ast.Node
|
||||||
func (r *HTMLRenderer) renderTaskCheckBoxListItem(w util.BufWriter, source []byte, node ast.Node, entering bool) (ast.WalkStatus, error) {
|
func (r *HTMLRenderer) renderTaskCheckBoxListItem(w util.BufWriter, source []byte, node ast.Node, entering bool) (ast.WalkStatus, error) {
|
||||||
n := node.(*TaskCheckBoxListItem)
|
n := node.(*TaskCheckBoxListItem)
|
||||||
if entering {
|
if entering {
|
||||||
n.Dump(source, 0)
|
|
||||||
if n.Attributes() != nil {
|
if n.Attributes() != nil {
|
||||||
_, _ = w.WriteString("<li")
|
_, _ = w.WriteString("<li")
|
||||||
html.RenderAttributes(w, n, html.ListItemAttributeFilter)
|
html.RenderAttributes(w, n, html.ListItemAttributeFilter)
|
||||||
|
|
Loading…
Reference in a new issue