Commit d0006e78 authored by Ian Lance Taylor's avatar Ian Lance Taylor

net: use newLocalListener in TestClosingListener.

Updates #21856

Change-Id: I9baa51fe23e6dd2fcf9dd14f7acfaf7457571e1d
Reviewed-on: https://go-review.googlesource.com/66334
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarDavid Crawshaw <crawshaw@golang.org>
Reviewed-by: default avatarMikio Hara <mikioh.mikioh@gmail.com>
parent 1591dad2
...@@ -700,15 +700,15 @@ func multicastRIBContains(ip IP) (bool, error) { ...@@ -700,15 +700,15 @@ func multicastRIBContains(ip IP) (bool, error) {
// Issue 21856. // Issue 21856.
func TestClosingListener(t *testing.T) { func TestClosingListener(t *testing.T) {
listener, err := Listen("tcp", ":0") ln, err := newLocalListener("tcp")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
addr := listener.Addr() addr := ln.Addr()
go func() { go func() {
for { for {
c, err := listener.Accept() c, err := ln.Accept()
if err != nil { if err != nil {
return return
} }
...@@ -721,10 +721,11 @@ func TestClosingListener(t *testing.T) { ...@@ -721,10 +721,11 @@ func TestClosingListener(t *testing.T) {
// testing anything, which is OK. // testing anything, which is OK.
time.Sleep(time.Millisecond) time.Sleep(time.Millisecond)
listener.Close() ln.Close()
_, err = Listen("tcp", addr.String()) ln, err = Listen("tcp", addr.String())
if err != nil { if err != nil {
t.Error(err) t.Fatal(err)
} }
ln.Close()
} }
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