mirror of
https://github.com/golang/go
synced 2024-11-19 05:54:44 -07:00
net/http: fix HTTP/2 idle pool tracing
CL 140357 caused HTTP/2 connections to be put in the idle pool, but failed to properly guard the trace.GotConn call in getConn. dialConn returns a minimal persistConn with conn == nil for HTTP/2 connections. This persistConn was then returned from queueForIdleConn and caused the httptrace.GotConnInfo passed into GotConn to have a nil Conn field. HTTP/2 connections call GotConn themselves so leave it for HTTP/2 to call GotConn as is done below.
This commit is contained in:
parent
79877e5f91
commit
7e1634c65c
@ -1195,7 +1195,9 @@ func (t *Transport) getConn(treq *transportRequest, cm connectMethod) (pc *persi
|
||||
// Queue for idle connection.
|
||||
if delivered := t.queueForIdleConn(w); delivered {
|
||||
pc := w.pc
|
||||
if trace != nil && trace.GotConn != nil {
|
||||
// Trace only for HTTP/1.
|
||||
// HTTP/2 calls trace.GotConn itself.
|
||||
if w.pc.alt == nil && trace != nil && trace.GotConn != nil {
|
||||
trace.GotConn(pc.gotIdleConnTrace(pc.idleAt))
|
||||
}
|
||||
// set request canceler to some non-nil function so we
|
||||
|
Loading…
Reference in New Issue
Block a user