From: Albert Strasheim Date: Tue, 24 Sep 2013 02:33:42 +0000 (-0400) Subject: net: fix Close of autobind unix listener X-Git-Tag: go1.2rc2~129 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=2be62360b2748636a2849e959dede7359383b200;p=gostls13.git net: fix Close of autobind unix listener Fixes #6455. R=mikioh.mikioh, rsc CC=golang-dev https://golang.org/cl/13457058 --- 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