]> Cypherpunks repositories - gostls13.git/commitdiff
net: close correct file descriptor when netpoll registration fails
authorAndrei Tudor Călin <mail@acln.ro>
Sat, 21 Sep 2019 18:17:40 +0000 (21:17 +0300)
committerIan Lance Taylor <iant@golang.org>
Mon, 23 Sep 2019 05:57:54 +0000 (05:57 +0000)
In (*netFD).accept, if initializing the *netFD associated with the
new connection fails, the listen FD is closed, rather than the FD
associated with the new connection. Close the correct FD instead.

Fixes #34392

Change-Id: I7bf3469d661e6d30cbd4b12f5f5fd330a81a541b
Reviewed-on: https://go-review.googlesource.com/c/go/+/196778
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/net/fd_unix.go

index dbe4a511ec84bbd3224e544e3bb5ab220abb1db4..4f59871f49fce7976c7f521b9fc088a7745e0b38 100644 (file)
@@ -248,7 +248,7 @@ func (fd *netFD) accept() (netfd *netFD, err error) {
                return nil, err
        }
        if err = netfd.init(); err != nil {
-               fd.Close()
+               netfd.Close()
                return nil, err
        }
        lsa, _ := syscall.Getsockname(netfd.pfd.Sysfd)