aboutsummaryrefslogtreecommitdiff
path: root/server.go
diff options
context:
space:
mode:
authorGravatar Erik Dubbelboer <erik@dubbelboer.com> 2022-04-01 15:54:02 +0200
committerGravatar Erik Dubbelboer <erik@dubbelboer.com> 2022-04-01 15:56:02 +0200
commitb4152d1a992acd8e257c11cc29b5eab98faae483 (patch)
tree198ab5cdbd75a40301f2b42d44e5da485d65d9f7 /server.go
parentState active (#1260) (diff)
downloadfasthttp-b4152d1a992acd8e257c11cc29b5eab98faae483.tar.gz
fasthttp-b4152d1a992acd8e257c11cc29b5eab98faae483.tar.bz2
fasthttp-b4152d1a992acd8e257c11cc29b5eab98faae483.zip
Only set RequestCtx.s once
We have a RequestCtx pool per server so we only need to set it once. This fixes a race codition where acquireCtx would assign .s while .Done() is reading it. Even though acquireCtx would always set it to the same, already assigned, value it would still trigger the race detector. Fixes: https://github.com/valyala/fasthttp/issues/1261
Diffstat (limited to 'server.go')
-rw-r--r--server.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/server.go b/server.go
index bc53247..a970e82 100644
--- a/server.go
+++ b/server.go
@@ -2634,11 +2634,11 @@ func (s *Server) acquireCtx(c net.Conn) (ctx *RequestCtx) {
ctx = new(RequestCtx)
ctx.Request.keepBodyBuffer = keepBodyBuffer
ctx.Response.keepBodyBuffer = keepBodyBuffer
+ ctx.s = s
} else {
ctx = v.(*RequestCtx)
}
- ctx.s = s
ctx.c = c
return ctx