diff options
author | Erik Dubbelboer <erik@dubbelboer.com> | 2022-04-01 15:54:02 +0200 |
---|---|---|
committer | Erik Dubbelboer <erik@dubbelboer.com> | 2022-04-01 15:56:02 +0200 |
commit | b4152d1a992acd8e257c11cc29b5eab98faae483 (patch) | |
tree | 198ab5cdbd75a40301f2b42d44e5da485d65d9f7 /server.go | |
parent | State active (#1260) (diff) | |
download | fasthttp-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.go | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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 |