diff options
| author | Michael Dusan <michael.dusan@gmail.com> | 2020-03-05 19:53:58 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-03-05 20:46:28 -0500 |
| commit | d31b65e762fbf59d29780d4cbf7be1ab824a67de (patch) | |
| tree | f264cc180948c1880b0173d782ec9d0546f818ba /lib/std/os.zig | |
| parent | 428677ea361447949f274587faa41656ce8199ab (diff) | |
| download | zig-d31b65e762fbf59d29780d4cbf7be1ab824a67de.tar.gz zig-d31b65e762fbf59d29780d4cbf7be1ab824a67de.zip | |
std: fix sendfile on macOS and FreeBSD
- fix std.os.sendfile/FreeBSD use correct in/out fd_t
- fix std.os.sendfile/macOS use correct in/out fd_t
- undo 1141bfb21b82f8d3fc353e968a591f2ad9aaa571 (no longer needed)
- fix c.freebsd.sendfile use off_t value
- fix c.freebsd.sendfile decl correct in/out fd_t
- fix c.darwin.sendfile decl correct in/out fd_t
fix signature param names
Diffstat (limited to 'lib/std/os.zig')
| -rw-r--r-- | lib/std/os.zig | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/std/os.zig b/lib/std/os.zig index 90ad3e03a9..a6c8b32ba9 100644 --- a/lib/std/os.zig +++ b/lib/std/os.zig @@ -3734,7 +3734,8 @@ pub fn sendfile( while (true) { var sbytes: off_t = undefined; - const err = errno(system.sendfile(out_fd, in_fd, in_offset, adjusted_count, hdtr, &sbytes, flags)); + const offset = @bitCast(off_t, in_offset); + const err = errno(system.sendfile(in_fd, out_fd, offset, adjusted_count, hdtr, &sbytes, flags)); const amt = @bitCast(usize, sbytes); switch (err) { 0 => return amt, @@ -3813,19 +3814,17 @@ pub fn sendfile( while (true) { var sbytes: off_t = adjusted_count; const signed_offset = @bitCast(i64, in_offset); - const err = errno(system.sendfile(out_fd, in_fd, signed_offset, &sbytes, hdtr, flags)); + const err = errno(system.sendfile(in_fd, out_fd, signed_offset, &sbytes, hdtr, flags)); const amt = @bitCast(usize, sbytes); switch (err) { 0 => return amt, + EBADF => unreachable, // Always a race condition. EFAULT => unreachable, // Segmentation fault. EINVAL => unreachable, ENOTCONN => unreachable, // `out_fd` is an unconnected socket. - // 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, + ENOTSUP, ENOTSOCK, ENOSYS => break :sf, EINTR => if (amt != 0) return amt else continue, |
