1. Dave Cheney
  2. go-debian-kfreebsd

Commits

Dave Cheney  committed bbc0024 Draft

net: remove unused nil check

This is part 1 of a series of proposals to fix issue 4369.

In resolving issue 3507 it was decided not to nil out the inner conn.fd field to avoid a race. This implies the checks for fd == nil inside incref/decref are never true.

Removing this logic removes one source of errClosing error values, which affects issue 4373 and moves towards bradfitz's request that fd.accept() return io.EOF when closed concurrently.

Update issue 4369.
Update issue 4373.

R=mikioh.mikioh, bradfitz, dvyukov, rsc
CC=golang-dev
http://codereview.appspot.com/6852057

  • Participants
  • Parent commits 11094b9
  • Branches default

Comments (0)

Files changed (2)

File src/pkg/net/fd_unix.go

View file
 // If closing==true, pollserver must be locked; mark the fd as closing.
 // Returns an error if the fd cannot be used.
 func (fd *netFD) incref(closing bool) error {
-	if fd == nil {
-		return errClosing
-	}
 	fd.sysmu.Lock()
 	if fd.closing {
 		fd.sysmu.Unlock()
 // Remove a reference to this FD and close if we've been asked to do so (and
 // there are no references left.
 func (fd *netFD) decref() {
-	if fd == nil {
-		return
-	}
 	fd.sysmu.Lock()
 	fd.sysref--
 	if fd.closing && fd.sysref == 0 && fd.sysfile != nil {

File src/pkg/net/unixsock_posix.go

View file
 	if l.path[0] != '@' {
 		syscall.Unlink(l.path)
 	}
-	err := l.fd.Close()
-	l.fd = nil
-	return err
+	return l.fd.Close()
 }
 
 // Addr returns the listener's network address.