diff options
author | Erik Dubbelboer <erik@dubbelboer.com> | 2022-03-04 10:02:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-04 10:02:47 +0100 |
commit | 62c15a5d098f23fcf7540841ed2377d4fd428956 (patch) | |
tree | e312731f02d9ff2682c2c1c117294427b246d526 /server.go | |
parent | Fix windows tests (#1235) (diff) | |
download | fasthttp-62c15a5d098f23fcf7540841ed2377d4fd428956.tar.gz fasthttp-62c15a5d098f23fcf7540841ed2377d4fd428956.tar.bz2 fasthttp-62c15a5d098f23fcf7540841ed2377d4fd428956.zip |
Don't reset RequestCtx.s (#1234)
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
Diffstat (limited to 'server.go')
-rw-r--r-- | server.go | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -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() } |