Commits

Dave Cheney  committed 5f24ff9 Draft

net: fix race between Close and Read

Fixes issue 3507.

Applied the suggested fix from rsc. If the connection
is in closing state then errClosing will bubble up to
the caller.

The fix has been applied to udp, ip and unix as well as
their code path include nil'ing c.fd on close. Func
tests are available in the linked issue that verified
the bug existed there as well.

R=rsc, fullung, alex.brainman, mikioh.mikioh
CC=golang-dev
http://codereview.appspot.com/6002053

  • Participants
  • Parent commits b25d41f

Comments (0)

Files changed (4)

File src/pkg/net/iprawsock_posix.go

 	if !c.ok() {
 		return syscall.EINVAL
 	}
-	err := c.fd.Close()
-	c.fd = nil
-	return err
+	return c.fd.Close()
 }
 
 // LocalAddr returns the local network address.

File src/pkg/net/tcpsock_posix.go

 	if !c.ok() {
 		return syscall.EINVAL
 	}
-	err := c.fd.Close()
-	c.fd = nil
-	return err
+	return c.fd.Close()
 }
 
 // CloseRead shuts down the reading side of the TCP connection.

File src/pkg/net/udpsock_posix.go

 	if !c.ok() {
 		return syscall.EINVAL
 	}
-	err := c.fd.Close()
-	c.fd = nil
-	return err
+	return c.fd.Close()
 }
 
 // LocalAddr returns the local network address.

File src/pkg/net/unixsock_posix.go

 	if !c.ok() {
 		return syscall.EINVAL
 	}
-	err := c.fd.Close()
-	c.fd = nil
-	return err
+	return c.fd.Close()
 }
 
 // LocalAddr returns the local network address, a *UnixAddr.