send_from_file(): Use sendfile() on Linux.

This commit is contained in:
Emil Mikulic 2003-11-22 13:10:57 +00:00
parent 8f4a5e6b60
commit df4f6910de

View File

@ -28,6 +28,7 @@
#ifdef __linux
#define _GNU_SOURCE /* for strsignal() and vasprintf() */
#include <sys/sendfile.h>
#endif
#include <sys/types.h>
@ -1683,6 +1684,9 @@ static ssize_t send_from_file(int s, FILE *fp, long ofs, size_t size)
return -1;
}
else return size;
#else
#ifdef __linux
return sendfile(s, fileno(fp), &ofs, size);
#else
#define BUFSIZE 20000
char buf[BUFSIZE];
@ -1693,6 +1697,7 @@ static ssize_t send_from_file(int s, FILE *fp, long ofs, size_t size)
if (fread(buf, amount, 1, fp) != 1) return -2;
return send(s, buf, amount, 0);
#endif
#endif
}