Commit c3bd93aa authored by Mikio Hara's avatar Mikio Hara Committed by Marcel van Lohuizen

net: don't leak test helper goroutine in TestAcceptTimeout

Fixes #15109.

Change-Id: Ibfdedd6807322ebec84bacfeb492fb53fe066960
Reviewed-on: https://go-review.googlesource.com/23742
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarMarcel van Lohuizen <mpvl@golang.org>
parent 9e112a3f
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
package net package net
import ( import (
"context"
"fmt" "fmt"
"internal/testenv" "internal/testenv"
"io" "io"
...@@ -164,10 +165,13 @@ func TestAcceptTimeout(t *testing.T) { ...@@ -164,10 +165,13 @@ func TestAcceptTimeout(t *testing.T) {
} }
defer ln.Close() defer ln.Close()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
for i, tt := range acceptTimeoutTests { for i, tt := range acceptTimeoutTests {
if tt.timeout < 0 { if tt.timeout < 0 {
go func() { go func() {
c, err := Dial(ln.Addr().Network(), ln.Addr().String()) var d Dialer
c, err := d.DialContext(ctx, ln.Addr().Network(), ln.Addr().String())
if err != nil { if err != nil {
t.Error(err) t.Error(err)
return return
......
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