Skip to content

Commit

Permalink
Only set RequestCtx.s once
Browse files Browse the repository at this point in the history
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: #1261
  • Loading branch information
erikdubbelboer committed Apr 1, 2022
1 parent d4c739e commit b4152d1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion server.go
Expand Up @@ -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
Expand Down

0 comments on commit b4152d1

Please sign in to comment.