Skip to content

Commit

Permalink
net: fix close on closed listener on Plan 9
Browse files Browse the repository at this point in the history
Since close errors have been cleaned up in CL 39997,
TestCloseError is failing on Plan 9, because
TCPListener.Close didn't check that the listener
has already been closed before writing the "hangup"
string to the listener control file.

This change fixes TCPListener.Close on Plan 9,
by closing poll.FD before writing the "hangup"
string.

Fixes golang#20128.

Change-Id: I13862b23a9055dd1be658acef7066707d98c591f
Reviewed-on: https://go-review.googlesource.com/41850
Run-TryBot: David du Colombier <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Brad Fitzpatrick <[email protected]>
  • Loading branch information
0intro committed Apr 26, 2017
1 parent aecf73f commit 8a4087a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/net/tcpsock_plan9.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ func (ln *TCPListener) accept() (*TCPConn, error) {
}

func (ln *TCPListener) close() error {
if err := ln.fd.pfd.Close(); err != nil {
return err
}
if _, err := ln.fd.ctl.WriteString("hangup"); err != nil {
ln.fd.ctl.Close()
return err
Expand Down

0 comments on commit 8a4087a

Please sign in to comment.