mirror of https://github.com/golang/go.git
net/http: fix Server.ConnContext modifying context for all new connections
Fixes #35750
This commit is contained in:
parent
8bbfc51d9a
commit
827fb3f45a
|
|
@ -2920,16 +2920,17 @@ func (srv *Server) Serve(l net.Listener) error {
|
|||
}
|
||||
return err
|
||||
}
|
||||
connCtx := ctx
|
||||
if cc := srv.ConnContext; cc != nil {
|
||||
ctx = cc(ctx, rw)
|
||||
if ctx == nil {
|
||||
connCtx = cc(connCtx, rw)
|
||||
if connCtx == nil {
|
||||
panic("ConnContext returned nil")
|
||||
}
|
||||
}
|
||||
tempDelay = 0
|
||||
c := srv.newConn(rw)
|
||||
c.setState(c.rwc, StateNew) // before Serve can return
|
||||
go c.serve(ctx)
|
||||
go c.serve(connCtx)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue