Skip to content

Commit

Permalink
net: close correct file descriptor when netpoll registration fails
Browse files Browse the repository at this point in the history
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 golang#34392

Change-Id: I7bf3469d661e6d30cbd4b12f5f5fd330a81a541b
Reviewed-on: https://go-review.googlesource.com/c/go/+/196778
Run-TryBot: Ian Lance Taylor <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
  • Loading branch information
acln0 authored and ianlancetaylor committed Sep 23, 2019
1 parent 20f0bcb commit 361ab73
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/net/fd_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 361ab73

Please sign in to comment.