Darwin can return EBADF for sendfile on non-files

This commit is contained in:
Andrew Kelley 2020-03-03 16:52:32 -05:00
parent c4f81586f1
commit 1141bfb21b

View File

@ -3818,12 +3818,14 @@ pub fn sendfile(
switch (err) { switch (err) {
0 => return amt, 0 => return amt,
EBADF => unreachable, // Always a race condition.
EFAULT => unreachable, // Segmentation fault. EFAULT => unreachable, // Segmentation fault.
EINVAL => unreachable, EINVAL => unreachable,
ENOTCONN => unreachable, // `out_fd` is an unconnected socket. ENOTCONN => unreachable, // `out_fd` is an unconnected socket.
ENOTSUP, ENOTSOCK, ENOSYS => break :sf, // On macOS version 10.14.6, I observed Darwin return EBADF when
// using sendfile on a valid open file descriptor of a file
// system file.
ENOTSUP, ENOTSOCK, ENOSYS, EBADF => break :sf,
EINTR => if (amt != 0) return amt else continue, EINTR => if (amt != 0) return amt else continue,