summaryrefslogtreecommitdiff
path: root/src/net/file_unix.go
diff options
context:
space:
mode:
authorMikio Hara <mikioh.mikioh@gmail.com>2015-03-01 12:27:01 +0900
committerMikio Hara <mikioh.mikioh@gmail.com>2015-03-31 23:07:42 +0000
commit29d1f3b85c8316f483164b16e459e10aacbe757e (patch)
tree534b3927036a738d908775207e63ee4990508b53 /src/net/file_unix.go
parentfa85a7206d46dc30d59cfd4e882b58a59a0a3d88 (diff)
downloadgo-git-29d1f3b85c8316f483164b16e459e10aacbe757e.tar.gz
net: add socket system call hooks for testing
This change adds socket system call hooks to existing test cases for simulating a bit complicated network conditions to help making timeout and dual IP stack test cases work more properly in followup changes. Also test cases print debugging information in non-short mode like the following: Leaked goroutines: net.TestWriteTimeout.func2(0xc20802a5a0, 0xc20801d000, 0x1000, 0x1000, 0xc2081d2ae0) /go/src/net/timeout_test.go:170 +0x98 created by net.TestWriteTimeout /go/src/net/timeout_test.go:173 +0x745 net.runDatagramPacketConnServer(0xc2080730e0, 0x2bd270, 0x3, 0x2c1770, 0xb, 0xc2081d2ba0, 0xc2081d2c00) /go/src/net/server_test.go:398 +0x667 created by net.TestTimeoutUDP /go/src/net/timeout_test.go:247 +0xc9 (snip) Leaked sockets: 3: {Cookie:615726511685632 Err:<nil> SocketErr:0} 5: {Cookie:7934075906097152 Err:<nil> SocketErr:0} Socket statistical information: {Family:1 Type:805306370 Protocol:0 Opened:17 Accepted:0 Connected:5 Closed:17} {Family:2 Type:805306369 Protocol:0 Opened:450 Accepted:234 Connected:279 Closed:636} {Family:1 Type:805306369 Protocol:0 Opened:11 Accepted:5 Connected:5 Closed:16} {Family:28 Type:805306369 Protocol:0 Opened:95 Accepted:22 Connected:16 Closed:116} {Family:2 Type:805306370 Protocol:0 Opened:84 Accepted:0 Connected:34 Closed:83} {Family:28 Type:805306370 Protocol:0 Opened:52 Accepted:0 Connected:4 Closed:52} Change-Id: I0e84be59a0699bc31245c78e2249423459b8cdda Reviewed-on: https://go-review.googlesource.com/6390 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/net/file_unix.go')
-rw-r--r--src/net/file_unix.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/net/file_unix.go b/src/net/file_unix.go
index 214a4196c8..8d806a1d63 100644
--- a/src/net/file_unix.go
+++ b/src/net/file_unix.go
@@ -18,13 +18,13 @@ func newFileFD(f *os.File) (*netFD, error) {
}
if err = syscall.SetNonblock(fd, true); err != nil {
- closesocket(fd)
+ closeFunc(fd)
return nil, err
}
sotype, err := syscall.GetsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_TYPE)
if err != nil {
- closesocket(fd)
+ closeFunc(fd)
return nil, os.NewSyscallError("getsockopt", err)
}
@@ -33,7 +33,7 @@ func newFileFD(f *os.File) (*netFD, error) {
lsa, _ := syscall.Getsockname(fd)
switch lsa.(type) {
default:
- closesocket(fd)
+ closeFunc(fd)
return nil, syscall.EINVAL
case *syscall.SockaddrInet4:
family = syscall.AF_INET
@@ -64,7 +64,7 @@ func newFileFD(f *os.File) (*netFD, error) {
netfd, err := newFD(fd, family, sotype, laddr.Network())
if err != nil {
- closesocket(fd)
+ closeFunc(fd)
return nil, err
}
if err := netfd.init(); err != nil {