aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/net/http/transport.go11
-rw-r--r--src/net/http/transport_test.go4
2 files changed, 5 insertions, 10 deletions
diff --git a/src/net/http/transport.go b/src/net/http/transport.go
index ca97489eea..20bfe0942d 100644
--- a/src/net/http/transport.go
+++ b/src/net/http/transport.go
@@ -1416,7 +1416,7 @@ func (t *Transport) dialConn(ctx context.Context, cm connectMethod) (*persistCon
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
}
}
@@ -2344,13 +2344,8 @@ func (pc *persistConn) closeLocked(err error) {
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()
diff --git a/src/net/http/transport_test.go b/src/net/http/transport_test.go
index cf2bbe1189..9de2fdab66 100644
--- a/src/net/http/transport_test.go
+++ b/src/net/http/transport_test.go
@@ -22,7 +22,6 @@ import (
"fmt"
"go/token"
"internal/nettrace"
- "internal/testenv"
"io"
"io/ioutil"
"log"
@@ -592,7 +591,7 @@ func TestTransportMaxConnsPerHostIncludeDialInProgress(t *testing.T) {
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 {
@@ -666,6 +665,7 @@ func TestTransportMaxConnsPerHost(t *testing.T) {
}
(<-connCh).Close()
+ tr.CloseIdleConnections()
doReq()
expected++