1
0
mirror of https://github.com/golang/go synced 2024-11-24 21:00:09 -07:00

net: fix linux build

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5558056
This commit is contained in:
Mikio Hara 2012-01-19 18:56:17 -08:00 committed by Brad Fitzpatrick
parent 8d6958fc04
commit 5e59e8537c

View File

@ -5,6 +5,7 @@
package net package net
import ( import (
"io"
"runtime" "runtime"
"testing" "testing"
) )
@ -33,24 +34,27 @@ func TestUnicastTCPAndUDP(t *testing.T) {
if tt.ipv6 && !supportsIPv6 { if tt.ipv6 && !supportsIPv6 {
continue continue
} }
var fd *netFD var (
fd *netFD
closer io.Closer
)
if !tt.packet { if !tt.packet {
if tt.laddr == "previous" { if tt.laddr == "previous" {
tt.laddr = prevladdr tt.laddr = prevladdr
} }
c, err := Listen(tt.net, tt.laddr) l, err := Listen(tt.net, tt.laddr)
if err != nil { if err != nil {
t.Fatalf("Listen failed: %v", err) t.Fatalf("Listen failed: %v", err)
} }
prevladdr = c.Addr().String() prevladdr = l.Addr().String()
defer c.Close() closer = l
fd = c.(*TCPListener).fd fd = l.(*TCPListener).fd
} else { } else {
c, err := ListenPacket(tt.net, tt.laddr) c, err := ListenPacket(tt.net, tt.laddr)
if err != nil { if err != nil {
t.Fatalf("ListenPacket failed: %v", err) t.Fatalf("ListenPacket failed: %v", err)
} }
defer c.Close() closer = c
fd = c.(*UDPConn).fd fd = c.(*UDPConn).fd
} }
if !tt.ipv6 { if !tt.ipv6 {
@ -58,6 +62,7 @@ func TestUnicastTCPAndUDP(t *testing.T) {
} else { } else {
testIPv6UnicastSocketOptions(t, fd) testIPv6UnicastSocketOptions(t, fd)
} }
closer.Close()
} }
} }