From 5e59e8537c6154862214bffb787a68f24ae58252 Mon Sep 17 00:00:00 2001 From: Mikio Hara Date: Thu, 19 Jan 2012 18:56:17 -0800 Subject: [PATCH] net: fix linux build R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/5558056 --- src/pkg/net/unicast_test.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/pkg/net/unicast_test.go b/src/pkg/net/unicast_test.go index a89b9baa5ef..297276d3a7f 100644 --- a/src/pkg/net/unicast_test.go +++ b/src/pkg/net/unicast_test.go @@ -5,6 +5,7 @@ package net import ( + "io" "runtime" "testing" ) @@ -33,24 +34,27 @@ func TestUnicastTCPAndUDP(t *testing.T) { if tt.ipv6 && !supportsIPv6 { continue } - var fd *netFD + var ( + fd *netFD + closer io.Closer + ) if !tt.packet { if tt.laddr == "previous" { tt.laddr = prevladdr } - c, err := Listen(tt.net, tt.laddr) + l, err := Listen(tt.net, tt.laddr) if err != nil { t.Fatalf("Listen failed: %v", err) } - prevladdr = c.Addr().String() - defer c.Close() - fd = c.(*TCPListener).fd + prevladdr = l.Addr().String() + closer = l + fd = l.(*TCPListener).fd } else { c, err := ListenPacket(tt.net, tt.laddr) if err != nil { t.Fatalf("ListenPacket failed: %v", err) } - defer c.Close() + closer = c fd = c.(*UDPConn).fd } if !tt.ipv6 { @@ -58,6 +62,7 @@ func TestUnicastTCPAndUDP(t *testing.T) { } else { testIPv6UnicastSocketOptions(t, fd) } + closer.Close() } }