Skip to content

Commit

Permalink
net: Set finalDeadline from TestDialParallel to avoid leaked sockets.
Browse files Browse the repository at this point in the history
I've also changed TestDialSerialAsyncSpuriousConnection for consistency,
although it always computes a finalDeadline of zero.

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

Fixes golang#11878

Change-Id: Ie0037dd3bce6cc81d196765375489f8c61be74c2
Reviewed-on: https://go-review.googlesource.com/12712
Reviewed-by: Russ Cox <[email protected]>
Run-TryBot: Paul Marks <[email protected]>
  • Loading branch information
Paul Marks committed Jul 28, 2015
1 parent 669f5be commit 85a5fce
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/net/dial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,13 +386,15 @@ func TestDialParallel(t *testing.T) {

primaries := makeAddrs(tt.primaries, dss.port)
fallbacks := makeAddrs(tt.fallbacks, dss.port)
d := Dialer{
FallbackDelay: fallbackDelay,
Timeout: slowTimeout,
}
ctx := &dialContext{
Dialer: Dialer{
FallbackDelay: fallbackDelay,
Timeout: slowTimeout,
},
network: "tcp",
address: "?",
Dialer: d,
network: "tcp",
address: "?",
finalDeadline: d.deadline(time.Now()),
}
startTime := time.Now()
c, err := dialParallel(ctx, primaries, fallbacks)
Expand Down Expand Up @@ -513,9 +515,12 @@ func TestDialSerialAsyncSpuriousConnection(t *testing.T) {
}
defer ln.Close()

d := Dialer{}
ctx := &dialContext{
network: "tcp",
address: "?",
Dialer: d,
network: "tcp",
address: "?",
finalDeadline: d.deadline(time.Now()),
}

results := make(chan dialResult)
Expand Down

0 comments on commit 85a5fce

Please sign in to comment.