]> Cypherpunks repositories - gostls13.git/commitdiff
net: remove unused nil check
authorDave Cheney <dave@cheney.net>
Sun, 18 Nov 2012 04:31:26 +0000 (15:31 +1100)
committerDave Cheney <dave@cheney.net>
Sun, 18 Nov 2012 04:31:26 +0000 (15:31 +1100)
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 #4369.
Update #4373.

R=mikioh.mikioh, bradfitz, dvyukov, rsc
CC=golang-dev
https://golang.org/cl/6852057

src/pkg/net/fd_unix.go
src/pkg/net/unixsock_posix.go

index f2f5ffa2f1918f42ed3762da876ba602473ce7e7..096ad41bbfad340f7f4ffe8572ab3e8913eb4aaa 100644 (file)
@@ -353,9 +353,6 @@ func (fd *netFD) connect(ra syscall.Sockaddr) error {
 // 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()
@@ -372,9 +369,6 @@ func (fd *netFD) incref(closing bool) error {
 // 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 {
index f7cc0746f22c56764802fdd9f2b07e2279914995..16ebd58d6e89dee1d48cc573b5c20788d8cf6832 100644 (file)
@@ -313,9 +313,7 @@ func (l *UnixListener) Close() error {
        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.