Commit 5e59e853 authored by Mikio Hara's avatar Mikio Hara Committed by Brad Fitzpatrick

net: fix linux build

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5558056
parent 8d6958fc
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
package net package net
import ( import (
"io"
"runtime" "runtime"
"testing" "testing"
) )
...@@ -33,24 +34,27 @@ func TestUnicastTCPAndUDP(t *testing.T) { ...@@ -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) { ...@@ -58,6 +62,7 @@ func TestUnicastTCPAndUDP(t *testing.T) {
} else { } else {
testIPv6UnicastSocketOptions(t, fd) testIPv6UnicastSocketOptions(t, fd)
} }
closer.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