diff options
author | David du Colombier <0intro@gmail.com> | 2016-04-18 22:37:33 +0200 |
---|---|---|
committer | David du Colombier <0intro@gmail.com> | 2016-04-18 21:58:54 +0000 |
commit | 262814467e7e574ac03114d23931042272fc714d (patch) | |
tree | b268575722f08b9cd1b3eaa8a5f6470607e8e9d4 /src | |
parent | f81ae3b22ca9cab78251b38fe52eacfea57e08f5 (diff) | |
download | go-git-262814467e7e574ac03114d23931042272fc714d.tar.gz |
net: handle hangup in read on Plan 9
On Plan 9, when closing a TCP connection, we
write the "hangup" string to the TCP ctl file.
The next read on the TCP data file will return
an error like "/net/tcp/18/data: Hangup", while
in Go, we expect to return io.EOF.
This change makes Read to return io.EOF when
an error string containing "Hangup" is returned.
Change-Id: I3f71ed543704190b441cac4787488a77f46d88a1
Reviewed-on: https://go-review.googlesource.com/22149
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/net/fd_plan9.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/net/fd_plan9.go b/src/net/fd_plan9.go index 35d1624317..329d6152b2 100644 --- a/src/net/fd_plan9.go +++ b/src/net/fd_plan9.go @@ -77,6 +77,9 @@ func (fd *netFD) Read(b []byte) (n int, err error) { } defer fd.readUnlock() n, err = fd.data.Read(b) + if isHangup(err) { + err = io.EOF + } if fd.net == "udp" && err == io.EOF { n = 0 err = nil @@ -179,3 +182,7 @@ func setReadBuffer(fd *netFD, bytes int) error { func setWriteBuffer(fd *netFD, bytes int) error { return syscall.EPLAN9 } + +func isHangup(err error) bool { + return err != nil && stringsHasSuffix(err.Error(), "Hangup") +} |