Skip to content

Commit 85a5fce

Browse files
author
Paul Marks
committed
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/12712 Reviewed-by: Russ Cox <[email protected]> Run-TryBot: Paul Marks <[email protected]>
1 parent 669f5be commit 85a5fce

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/net/dial_test.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -386,13 +386,15 @@ func TestDialParallel(t *testing.T) {
386386

387387
primaries := makeAddrs(tt.primaries, dss.port)
388388
fallbacks := makeAddrs(tt.fallbacks, dss.port)
389+
d := Dialer{
390+
FallbackDelay: fallbackDelay,
391+
Timeout: slowTimeout,
392+
}
389393
ctx := &dialContext{
390-
Dialer: Dialer{
391-
FallbackDelay: fallbackDelay,
392-
Timeout: slowTimeout,
393-
},
394-
network: "tcp",
395-
address: "?",
394+
Dialer: d,
395+
network: "tcp",
396+
address: "?",
397+
finalDeadline: d.deadline(time.Now()),
396398
}
397399
startTime := time.Now()
398400
c, err := dialParallel(ctx, primaries, fallbacks)
@@ -513,9 +515,12 @@ func TestDialSerialAsyncSpuriousConnection(t *testing.T) {
513515
}
514516
defer ln.Close()
515517

518+
d := Dialer{}
516519
ctx := &dialContext{
517-
network: "tcp",
518-
address: "?",
520+
Dialer: d,
521+
network: "tcp",
522+
address: "?",
523+
finalDeadline: d.deadline(time.Now()),
519524
}
520525

521526
results := make(chan dialResult)

0 commit comments

Comments
 (0)