Skip to content

Commit 827fb3f

Browse files
committed
net/http: fix Server.ConnContext modifying context for all new connections
Fixes #35750
1 parent 8bbfc51 commit 827fb3f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/net/http/server.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2920,16 +2920,17 @@ func (srv *Server) Serve(l net.Listener) error {
29202920
}
29212921
return err
29222922
}
2923+
connCtx := ctx
29232924
if cc := srv.ConnContext; cc != nil {
2924-
ctx = cc(ctx, rw)
2925-
if ctx == nil {
2925+
connCtx = cc(connCtx, rw)
2926+
if connCtx == nil {
29262927
panic("ConnContext returned nil")
29272928
}
29282929
}
29292930
tempDelay = 0
29302931
c := srv.newConn(rw)
29312932
c.setState(c.rwc, StateNew) // before Serve can return
2932-
go c.serve(ctx)
2933+
go c.serve(connCtx)
29332934
}
29342935
}
29352936

0 commit comments

Comments
 (0)