]> Cypherpunks repositories - gostls13.git/commitdiff
net: fix close on closed listener on Plan 9
authorDavid du Colombier <0intro@gmail.com>
Wed, 26 Apr 2017 07:27:15 +0000 (09:27 +0200)
committerDavid du Colombier <0intro@gmail.com>
Wed, 26 Apr 2017 15:04:43 +0000 (15:04 +0000)
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 #20128.

Change-Id: I13862b23a9055dd1be658acef7066707d98c591f
Reviewed-on: https://go-review.googlesource.com/41850
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/net/tcpsock_plan9.go

index d2860607f8b9be253388dd412555c208d3036b7c..e37f0657c079819e5bd3173e5931409b2ff6f14c 100644 (file)
@@ -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