Sendfile in Linux and FreeBSD are different. - geomyidae - A small C-based gopherd. HTML git clone git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/geomyidae/ DIR Log DIR Files DIR Refs DIR Tags DIR README DIR LICENSE --- DIR commit c89bef327e78a4c0400b3665d249d36af6a3160b DIR parent eb18ab03d6c767aa5f355d802b00ad7ec2a3055f HTML Author: Christoph Lohmann <20h@r-36.net> Date: Thu, 23 Aug 2018 14:00:21 +0200 Sendfile in Linux and FreeBSD are different. Diffstat: M ind.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) --- DIR diff --git a/ind.c b/ind.c @@ -174,18 +174,16 @@ xsendfile(int fd, int sock) } /* Different sendfile(2) implementations on different platforms. :/ */ -#if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__) - for (sent = 0; count > 0; count -= sent) { #ifdef __linux__ + for (sent = 0; count > 0; count -= sent) { sent = sendfile(sock, fd, 0, count); -#endif -#if defined(__FreeBSD__) || defined(__DragonFly__) - sent = sendfile(fd, sock, 0, count, NULL, NULL, 0); -#endif if (sent < 0) return -1; } #endif +#if defined(__FreeBSD__) || defined(__DragonFly__) + return sendfile(fd, sock, 0, count, NULL, NULL, 0); +#endif return 0; }