if s := pconn.tlsState; s != nil && s.NegotiatedProtocolIsMutual && s.NegotiatedProtocol != "" {
if next, ok := t.TLSNextProto[s.NegotiatedProtocol]; ok {
- return &persistConn{cacheKey: pconn.cacheKey, alt: next(cm.targetAddr, pconn.conn.(*tls.Conn))}, nil
+ return &persistConn{t: t, cacheKey: pconn.cacheKey, alt: next(cm.targetAddr, pconn.conn.(*tls.Conn))}, nil
}
}
if pc.closed == nil {
pc.closed = err
if pc.alt != nil {
- // Do nothing; can only get here via getConn's
- // handlePendingDial's putOrCloseIdleConn when
- // it turns out the abandoned connection in
- // flight ended up negotiating an alternate
- // protocol. We don't use the connection
- // freelist for http2. That's done by the
- // alternate protocol's RoundTripper.
+ // Clean up any host connection counting.
+ pc.t.decHostConnCount(pc.cacheKey)
} else {
if err != errCallerOwnsConn {
pc.conn.Close()
"fmt"
"go/token"
"internal/nettrace"
- "internal/testenv"
"io"
"io/ioutil"
"log"
func TestTransportMaxConnsPerHost(t *testing.T) {
defer afterTest(t)
- testenv.SkipFlaky(t, 31784)
+
h := HandlerFunc(func(w ResponseWriter, r *Request) {
_, err := w.Write([]byte("foo"))
if err != nil {
}
(<-connCh).Close()
+ tr.CloseIdleConnections()
doReq()
expected++