mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
net: fix netFD.Close races
Fixes #271. Fixes #321. R=rsc, agl, cw CC=golang-dev https://golang.org/cl/163052
This commit is contained in:
parent
ff3ea68e52
commit
eb16346dac
5 changed files with 98 additions and 75 deletions
|
|
@ -332,9 +332,9 @@ func ListenUnix(net string, laddr *UnixAddr) (l *UnixListener, err os.Error) {
|
|||
}
|
||||
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 @@ func ListenUnix(net string, laddr *UnixAddr) (l *UnixListener, err os.Error) {
|
|||
// 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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue