Do more sendfile, in case sendfile did not send everything. - 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 eb18ab03d6c767aa5f355d802b00ad7ec2a3055f DIR parent efab0d1f664ac58350ead1e8e7259a31916babe1 HTML Author: Christoph Lohmann <20h@r-36.net> Date: Thu, 23 Aug 2018 13:42:28 +0200 Do more sendfile, in case sendfile did not send everything. Diffstat: M ind.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) --- DIR diff --git a/ind.c b/ind.c @@ -174,13 +174,20 @@ 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__ - return sendfile(sock, fd, NULL, count); + sent = sendfile(sock, fd, 0, count); #endif #if defined(__FreeBSD__) || defined(__DragonFly__) - return sendfile(fd, sock, 0, count, NULL, NULL, 0); + sent = sendfile(fd, sock, 0, count, NULL, NULL, 0); #endif - return -1; + if (sent < 0) + return -1; + } +#endif + + return 0; } void *