From 8464efa5dd792de25ee8faa413c89f1daf8b5efb Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 18 Feb 2025 23:30:46 -0800 Subject: [PATCH] std.posix.sendfile: don't write trailers on linux After sending the file, better to return total bytes written. The caller will decide if they want to do another syscall with the trailers. Maybe the caller would rather buffer them. --- lib/std/posix.zig | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/lib/std/posix.zig b/lib/std/posix.zig index 7a517b9a47..414a9289b3 100644 --- a/lib/std/posix.zig +++ b/lib/std/posix.zig @@ -6092,17 +6092,13 @@ pub const SendError = error{ pub const SendMsgError = SendError || error{ /// The passed address didn't have the correct address family in its sa_family field. AddressFamilyNotSupported, - /// Returned when socket is AF.UNIX and the given path has a symlink loop. SymLinkLoop, - /// Returned when socket is AF.UNIX and the given path length exceeds `max_path_bytes` bytes. NameTooLong, - /// Returned when socket is AF.UNIX and the given path does not point to an existing file. FileNotFound, NotDir, - /// The socket is not connected (connection-oriented sockets only). SocketNotConnected, AddressNotAvailable, @@ -6400,14 +6396,7 @@ pub fn sendfile( .SUCCESS => { const amt: usize = @bitCast(rc); total_written += amt; - if (in_len == 0 and amt == 0) { - // We have detected EOF from `in_fd`. - break; - } else if (amt < in_len) { - return total_written; - } else { - break; - } + return total_written; }, .BADF => unreachable, // Always a race condition.