aboutsummaryrefslogtreecommitdiff
path: root/server.go
diff options
context:
space:
mode:
authorGravatar Erik Dubbelboer <erik@dubbelboer.com> 2022-03-04 10:02:47 +0100
committerGravatar GitHub <noreply@github.com> 2022-03-04 10:02:47 +0100
commit62c15a5d098f23fcf7540841ed2377d4fd428956 (patch)
treee312731f02d9ff2682c2c1c117294427b246d526 /server.go
parentFix windows tests (#1235) (diff)
downloadfasthttp-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.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/server.go b/server.go
index 1a8ba8c..3b58542 100644
--- a/server.go
+++ b/server.go
@@ -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()
}