diff options
author | David du Colombier <0intro@gmail.com> | 2014-10-28 22:44:59 +0100 |
---|---|---|
committer | David du Colombier <0intro@gmail.com> | 2014-10-28 22:44:59 +0100 |
commit | 5f54f06a359f2973521ff3f42899c12d3a6a7fed (patch) | |
tree | f97705e681056e55f41656343e2951f43dc625bf | |
parent | 982dcb249d107c1cab844912583c5eca0a07a00f (diff) | |
download | go-5f54f06a359f2973521ff3f42899c12d3a6a7fed.tar.gz go-5f54f06a359f2973521ff3f42899c12d3a6a7fed.zip |
os: fix write on Plan 9
In CL 160670043 the write function was changed
so a zero-length write is now allowed. This leads
the ExampleWriter_Init test to fail.
The reason is that Plan 9 preserves message
boundaries, while the os library expects systems
that don't preserve them. We have to ignore
zero-length writes so they will never turn into EOF.
This issue was previously discussed in CL 7406046.
LGTM=bradfitz
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/163510043
-rw-r--r-- | src/os/file_plan9.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/os/file_plan9.go b/src/os/file_plan9.go index 22860e20af..5efc2a4f1d 100644 --- a/src/os/file_plan9.go +++ b/src/os/file_plan9.go @@ -259,6 +259,9 @@ func (f *File) pread(b []byte, off int64) (n int, err error) { // Since Plan 9 preserves message boundaries, never allow // a zero-byte write. func (f *File) write(b []byte) (n int, err error) { + if len(b) == 0 { + return 0, nil + } return fixCount(syscall.Write(f.fd, b)) } |