Skip to content

Commit

Permalink
Make sure to reset the userValues always and at the exact time (#1027)
Browse files Browse the repository at this point in the history
* Ensure reset userValues always that release RequestCtx

* Reset userValues after response write and hijack handler are executed
  • Loading branch information
Sergio Andrés Virviescas Santana committed May 22, 2021
1 parent a18c632 commit b433ecf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2237,8 +2237,6 @@ func (s *Server) serveConn(c net.Conn) (err error) {
hijackNoResponse = ctx.hijackNoResponse && hijackHandler != nil
ctx.hijackNoResponse = false

ctx.userValues.Reset()

if s.MaxRequestsPerConn > 0 && connRequestNum >= uint64(s.MaxRequestsPerConn) {
ctx.SetConnectionClose()
}
Expand Down Expand Up @@ -2329,6 +2327,7 @@ func (s *Server) serveConn(c net.Conn) (err error) {
}

s.setState(c, StateIdle)
ctx.userValues.Reset()

if atomic.LoadInt32(&s.stop) == 1 {
err = nil
Expand Down Expand Up @@ -2651,6 +2650,7 @@ func (s *Server) releaseCtx(ctx *RequestCtx) {
ctx.c = nil
ctx.remoteAddr = nil
ctx.fbr.c = nil
ctx.userValues.Reset()
s.ctxPool.Put(ctx)
}

Expand Down

0 comments on commit b433ecf

Please sign in to comment.