diff options
author | Ian Lance Taylor <iant@golang.org> | 2021-02-14 17:14:41 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2021-02-16 21:22:54 +0000 |
commit | 023c46676db26e75d244b1d38ccc4a4b8bfe3eef (patch) | |
tree | ba4dbda6bd8945fd4f87e7c7209a5948e0da6659 /src/net/sendfile_test.go | |
parent | fa6752a5370735b8c2404d6de5191f2eea67130f (diff) | |
download | go-023c46676db26e75d244b1d38ccc4a4b8bfe3eef.tar.gz go-023c46676db26e75d244b1d38ccc4a4b8bfe3eef.zip |
[release-branch.go1.15] internal/poll: if copy_file_range returns 0, assume it failed
On current Linux kernels copy_file_range does not correctly handle
files in certain special file systems, such as /proc. For those file
systems it fails to copy any data and returns zero. This breaks Go's
io.Copy for those files.
Fix the problem by assuming that if copy_file_range returns 0 the
first time it is called on a file, that that file is not supported.
In that case fall back to just using read. This will force an extra
system call when using io.Copy to copy a zero-sized normal file,
but at least it will work correctly.
For #36817
For #44272
Fixes #44273
Change-Id: I02e81872cb70fda0ce5485e2ea712f219132e614
Reviewed-on: https://go-review.googlesource.com/c/go/+/291989
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
(cherry picked from commit 30641e36aa5b547eee48565caa3078b0a2e7c185)
Reviewed-on: https://go-review.googlesource.com/c/go/+/292289
Diffstat (limited to 'src/net/sendfile_test.go')
0 files changed, 0 insertions, 0 deletions