Skip to content

Commit

Permalink
reset request before ctx release; fixes #548
Browse files Browse the repository at this point in the history
Signed-off-by: Kirill Danshin <kirill@danshin.pro>
  • Loading branch information
kirillDanshin committed Mar 2, 2019
1 parent 733a650 commit 64c234a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1829,6 +1829,8 @@ func (s *Server) serveConn(c net.Conn) error {

connectionClose bool
isHTTP11 bool

reqReset bool
)
for {
connRequestNum++
Expand Down Expand Up @@ -1944,6 +1946,7 @@ func (s *Server) serveConn(c net.Conn) error {
if !ctx.IsGet() && ctx.IsHead() {
ctx.Response.SkipBody = true
}
reqReset = true
ctx.Request.Reset()

hijackHandler = ctx.hijackHandler
Expand Down Expand Up @@ -2039,6 +2042,12 @@ func (s *Server) serveConn(c net.Conn) error {
if bw != nil {
releaseWriter(s, bw)
}
// in unexpected cases the for loop will break
// before request reset call. in such cases, call it before
// release to fix #548
if !reqReset {
ctx.Request.Reset()
}
s.releaseCtx(ctx)
return err
}
Expand Down

0 comments on commit 64c234a

Please sign in to comment.