mirror of
https://github.com/golang/go
synced 2024-11-17 14:14:56 -07:00
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: David Crawshaw <crawshaw@golang.org> Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
This commit is contained in:
parent
1591dad274
commit
d0006e7868
@ -700,15 +700,15 @@ func multicastRIBContains(ip IP) (bool, error) {
|
||||
|
||||
// Issue 21856.
|
||||
func TestClosingListener(t *testing.T) {
|
||||
listener, err := Listen("tcp", ":0")
|
||||
ln, err := newLocalListener("tcp")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
addr := listener.Addr()
|
||||
addr := ln.Addr()
|
||||
|
||||
go func() {
|
||||
for {
|
||||
c, err := listener.Accept()
|
||||
c, err := ln.Accept()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -721,10 +721,11 @@ func TestClosingListener(t *testing.T) {
|
||||
// testing anything, which is OK.
|
||||
time.Sleep(time.Millisecond)
|
||||
|
||||
listener.Close()
|
||||
ln.Close()
|
||||
|
||||
_, err = Listen("tcp", addr.String())
|
||||
ln, err = Listen("tcp", addr.String())
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
ln.Close()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user