Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reset request before ctx release; fixes #548 #551

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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