From: Russ Cox Date: Fri, 2 May 2014 16:12:40 +0000 (-0400) Subject: os: cut limited read to 1 GB X-Git-Tag: go1.3beta2~154 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=3879f0abcd94598723d6c3024e5006b52b736b7b;p=gostls13.git os: cut limited read to 1 GB If systems actually read that much, using 2GB-1 will result in misaligned subsequent reads. Use 1GB instead, which will certainly keep reads aligned and which is plenty large enough. Update #7812. LGTM=bradfitz R=bradfitz CC=golang-codereviews https://golang.org/cl/94070044 --- diff --git a/src/pkg/os/file_unix.go b/src/pkg/os/file_unix.go index bc478b1cc5..76168339d2 100644 --- a/src/pkg/os/file_unix.go +++ b/src/pkg/os/file_unix.go @@ -174,9 +174,11 @@ func (f *File) readdir(n int) (fi []FileInfo, err error) { // Darwin and FreeBSD can't read or write 2GB+ at a time, // even on 64-bit systems. See golang.org/issue/7812. +// Use 1GB instead of, say, 2GB-1, to keep subsequent +// reads aligned. const ( needsMaxRW = runtime.GOOS == "darwin" || runtime.GOOS == "freebsd" - maxRW = 2<<30 - 1 + maxRW = 1 << 30 ) // read reads up to len(b) bytes from the File.