]> Cypherpunks repositories - gostls13.git/commitdiff
os: fix write on Plan 9
authorDavid du Colombier <0intro@gmail.com>
Tue, 28 Oct 2014 21:44:59 +0000 (22:44 +0100)
committerDavid du Colombier <0intro@gmail.com>
Tue, 28 Oct 2014 21:44:59 +0000 (22:44 +0100)
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

src/os/file_plan9.go

index 22860e20af7e94b4ed99b6c2979b55ffca923922..5efc2a4f1dbb375f9f8db90c0dc177ea04309e14 100644 (file)
@@ -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))
 }