net: fix netFD.Close races
Fixes #271.
Fixes #321.
R=rsc, agl, cw
CC=golang-dev
https://golang.org/cl/163052
diff --git a/src/pkg/net/unixsock.go b/src/pkg/net/unixsock.go
index 6572e85..4ac3be5 100644
--- a/src/pkg/net/unixsock.go
+++ b/src/pkg/net/unixsock.go
@@ -332,9 +332,9 @@
}
return nil, e;
}
- e1 := syscall.Listen(fd.fd, 8); // listenBacklog());
+ e1 := syscall.Listen(fd.sysfd, 8); // listenBacklog());
if e1 != 0 {
- syscall.Close(fd.fd);
+ syscall.Close(fd.sysfd);
return nil, &OpError{"listen", "unix", laddr, os.Errno(e1)};
}
return &UnixListener{fd, laddr.Name}, nil;
@@ -343,7 +343,7 @@
// AcceptUnix accepts the next incoming call and returns the new connection
// and the remote address.
func (l *UnixListener) AcceptUnix() (c *UnixConn, err os.Error) {
- if l == nil || l.fd == nil || l.fd.fd < 0 {
+ if l == nil || l.fd == nil {
return nil, os.EINVAL
}
fd, e := l.fd.accept(sockaddrToUnix);