Skip to content

Commit

Permalink
Test: fix http2 dial timeout (#570)
Browse files Browse the repository at this point in the history
* fix http2 dial timeout
  • Loading branch information
kslr committed Jan 11, 2021
1 parent 78e01a3 commit 405a051
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion testing/scenarios/tls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ func TestHTTP2(t *testing.T) {

var errg errgroup.Group
for i := 0; i < 10; i++ {
errg.Go(testTCPConn(clientPort, 10240*1024, time.Second*40))
errg.Go(testTCPConn(clientPort, 7168*1024, time.Second*40))
}
if err := errg.Wait(); err != nil {
t.Error(err)
Expand Down
7 changes: 2 additions & 5 deletions transport/internet/http/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var (
globalDialerAccess sync.Mutex
)

func getHTTPClient(_ context.Context, dest net.Destination, tlsSettings *tls.Config) *http.Client {
func getHTTPClient(ctx context.Context, dest net.Destination, tlsSettings *tls.Config) *http.Client {
globalDialerAccess.Lock()
defer globalDialerAccess.Unlock()

Expand All @@ -50,7 +50,7 @@ func getHTTPClient(_ context.Context, dest net.Destination, tlsSettings *tls.Con
}
address := net.ParseAddress(rawHost)

pconn, err := internet.DialSystem(context.Background(), net.TCPDestination(address, port), nil)
pconn, err := internet.DialSystem(ctx, net.TCPDestination(address, port), nil)
if err != nil {
return nil, err
}
Expand All @@ -68,9 +68,6 @@ func getHTTPClient(_ context.Context, dest net.Destination, tlsSettings *tls.Con
if p := state.NegotiatedProtocol; p != http2.NextProtoTLS {
return nil, newError("http2: unexpected ALPN protocol " + p + "; want q" + http2.NextProtoTLS).AtError()
}
if !state.NegotiatedProtocolIsMutual {
return nil, newError("http2: could not negotiate protocol mutually").AtError()
}
return cn, nil
},
TLSClientConfig: tlsSettings.GetTLSConfig(tls.WithDestination(dest)),
Expand Down

0 comments on commit 405a051

Please sign in to comment.