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: Marcel van Lohuizen <mpvl@golang.org>
This commit is contained in:
Mikio Hara 2016-06-03 18:06:54 +09:00 committed by Marcel van Lohuizen
parent 9e112a3fe4
commit c3bd93aa26
1 changed files with 5 additions and 1 deletions

View File

@ -5,6 +5,7 @@
package net
import (
"context"
"fmt"
"internal/testenv"
"io"
@ -164,10 +165,13 @@ func TestAcceptTimeout(t *testing.T) {
}
defer ln.Close()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
for i, tt := range acceptTimeoutTests {
if tt.timeout < 0 {
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 {
t.Error(err)
return