Make sure to reset the userValues always and at the exact time (#1027)

* Ensure reset userValues always that release RequestCtx

* Reset userValues after response write and hijack handler are executed
This commit is contained in:
Sergio Andrés Virviescas Santana
2021-05-22 17:23:41 +02:00
committed by GitHub
parent a18c6322a2
commit b433ecfcbd
+2 -2
View File
@@ -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()
}
@@ -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
@@ -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)
}