Commit 85a5fce7 authored by Paul Marks's avatar Paul Marks

net: Set finalDeadline from TestDialParallel to avoid leaked sockets.

I've also changed TestDialSerialAsyncSpuriousConnection for consistency,
although it always computes a finalDeadline of zero.

Note that #11225 is the root cause of the socket leak; this just hides
it from the unit test by restoring the shorter timeout.

Fixes #11878

Change-Id: Ie0037dd3bce6cc81d196765375489f8c61be74c2
Reviewed-on: https://go-review.googlesource.com/12712Reviewed-by: default avatarRuss Cox <rsc@golang.org>
Run-TryBot: Paul Marks <pmarks@google.com>
parent 669f5be2
...@@ -386,13 +386,15 @@ func TestDialParallel(t *testing.T) { ...@@ -386,13 +386,15 @@ func TestDialParallel(t *testing.T) {
primaries := makeAddrs(tt.primaries, dss.port) primaries := makeAddrs(tt.primaries, dss.port)
fallbacks := makeAddrs(tt.fallbacks, dss.port) fallbacks := makeAddrs(tt.fallbacks, dss.port)
d := Dialer{
FallbackDelay: fallbackDelay,
Timeout: slowTimeout,
}
ctx := &dialContext{ ctx := &dialContext{
Dialer: Dialer{ Dialer: d,
FallbackDelay: fallbackDelay, network: "tcp",
Timeout: slowTimeout, address: "?",
}, finalDeadline: d.deadline(time.Now()),
network: "tcp",
address: "?",
} }
startTime := time.Now() startTime := time.Now()
c, err := dialParallel(ctx, primaries, fallbacks) c, err := dialParallel(ctx, primaries, fallbacks)
...@@ -513,9 +515,12 @@ func TestDialSerialAsyncSpuriousConnection(t *testing.T) { ...@@ -513,9 +515,12 @@ func TestDialSerialAsyncSpuriousConnection(t *testing.T) {
} }
defer ln.Close() defer ln.Close()
d := Dialer{}
ctx := &dialContext{ ctx := &dialContext{
network: "tcp", Dialer: d,
address: "?", network: "tcp",
address: "?",
finalDeadline: d.deadline(time.Now()),
} }
results := make(chan dialResult) results := make(chan dialResult)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment