From 2be62360b2748636a2849e959dede7359383b200 Mon Sep 17 00:00:00 2001 From: Albert Strasheim Date: Mon, 23 Sep 2013 22:33:42 -0400 Subject: [PATCH] net: fix Close of autobind unix listener Fixes #6455. R=mikioh.mikioh, rsc CC=golang-dev https://golang.org/cl/13457058 --- src/pkg/net/unix_test.go | 14 +++++++++++++- src/pkg/net/unixsock_posix.go | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/pkg/net/unix_test.go b/src/pkg/net/unix_test.go index eae9f3f6d1..91df3ff887 100644 --- a/src/pkg/net/unix_test.go +++ b/src/pkg/net/unix_test.go @@ -107,7 +107,7 @@ func TestReadUnixgramWithZeroBytesBuffer(t *testing.T) { } } -func TestUnixAutobind(t *testing.T) { +func TestUnixgramAutobind(t *testing.T) { if runtime.GOOS != "linux" { t.Skip("skipping: autobind is linux only") } @@ -139,6 +139,18 @@ func TestUnixAutobind(t *testing.T) { } } +func TestUnixAutobindClose(t *testing.T) { + if runtime.GOOS != "linux" { + t.Skip("skipping: autobind is linux only") + } + laddr := &UnixAddr{Name: "", Net: "unix"} + ln, err := ListenUnix("unix", laddr) + if err != nil { + t.Fatalf("ListenUnix failed: %v", err) + } + ln.Close() +} + func TestUnixConnLocalAndRemoteNames(t *testing.T) { for _, laddr := range []string{"", testUnixAddr()} { laddr := laddr diff --git a/src/pkg/net/unixsock_posix.go b/src/pkg/net/unixsock_posix.go index 08ea24a430..b82f3cee0b 100644 --- a/src/pkg/net/unixsock_posix.go +++ b/src/pkg/net/unixsock_posix.go @@ -271,7 +271,7 @@ func ListenUnix(net string, laddr *UnixAddr) (*UnixListener, error) { if err != nil { return nil, &OpError{Op: "listen", Net: net, Addr: laddr, Err: err} } - return &UnixListener{fd, laddr.Name}, nil + return &UnixListener{fd, fd.laddr.String()}, nil } // AcceptUnix accepts the next incoming call and returns the new -- 2.48.1