]> Cypherpunks repositories - gostls13.git/commitdiff
net: close the connection gracefully on Plan 9
authorDavid du Colombier <0intro@gmail.com>
Mon, 17 Oct 2016 17:15:37 +0000 (19:15 +0200)
committerDavid du Colombier <0intro@gmail.com>
Tue, 18 Oct 2016 12:56:52 +0000 (12:56 +0000)
Previously, we used to write the "hangup" message to
the TCP connection control file to be able to close
a connection, while waking up the readers.

The "hangup" message closes the TCP connection with a
RST message. This is a problem when closing a connection
consecutively to a write, because the reader may not have
time to acknowledge the message before the connection is
closed, resulting in loss of data.

We use a "close" message, newly implemented in the Plan 9
kernel to be able to close a TCP connection gracefully with a FIN.

Updates #15464.

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

index 7533232dc9b5eb27c3b74b584f2b4efcf1779220..e7dea696e71782ec0bb80464e67abafe9a8d20d3 100644 (file)
@@ -128,7 +128,7 @@ func (fd *netFD) Close() error {
                // "write /net/tcp/39/listen: inappropriate use of fd"
                // But without it, Reads on dead conns hang forever.
                // See Issue 9554.
-               fd.ctl.WriteString("hangup")
+               fd.ctl.WriteString("close")
        }
        err := fd.ctl.Close()
        if fd.data != nil {