Skip to content

Commit

Permalink
Don't reset RequestCtx.s (#1234)
Browse files Browse the repository at this point in the history
RequestCtx's are reused in a server specific pool, so no need to reset
it. This fixes a use after reset but when RequestCtx is use as context.

Fixes #1205
  • Loading branch information
erikdubbelboer authored Mar 4, 2022
1 parent 7670c6e commit 62c15a5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -788,9 +788,14 @@ func (ctx *RequestCtx) reset() {
ctx.connTime = zeroTime
ctx.remoteAddr = nil
ctx.time = zeroTime
ctx.s = nil
ctx.c = nil

// Don't reset ctx.s!
// We have a pool per server so the next time this ctx is used it
// will be assigned the same value again.
// ctx might still be in use for context.Done() and context.Err()
// which are safe to use as they only use ctx.s and no other value.

if ctx.timeoutResponse != nil {
ctx.timeoutResponse.Reset()
}
Expand Down

0 comments on commit 62c15a5

Please sign in to comment.