]> Cypherpunks repositories - gostls13.git/commitdiff
net: fix Close of autobind unix listener
authorAlbert Strasheim <fullung@gmail.com>
Tue, 24 Sep 2013 02:33:42 +0000 (22:33 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 24 Sep 2013 02:33:42 +0000 (22:33 -0400)
Fixes #6455.

R=mikioh.mikioh, rsc
CC=golang-dev
https://golang.org/cl/13457058

src/pkg/net/unix_test.go
src/pkg/net/unixsock_posix.go

index eae9f3f6d194b6bf52131ce312a3e862e72b9d13..91df3ff88769bc53454a9d4c7765a5aa349cbf5c 100644 (file)
@@ -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
index 08ea24a4305a71fd1c39bedd1dc74a54a74cb2ec..b82f3cee0b57d21fa83b77b7c1928135b982300d 100644 (file)
@@ -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