Merge branch 'master' into storageareas

This commit is contained in:
Isaac Connor 2017-06-22 10:00:28 -04:00
commit a29ad958c9
1 changed files with 14 additions and 14 deletions

View File

@ -1,30 +1,30 @@
#ifdef HAVE_SENDFILE4_SUPPORT #ifdef HAVE_SENDFILE4_SUPPORT
#include <sys/sendfile.h> #include <sys/sendfile.h>
int zm_sendfile(int out_fd, int in_fd, off_t *offset, size_t size) { int zm_sendfile(int out_fd, int in_fd, off_t *offset, size_t size) {
int err; int err;
err = sendfile(out_fd, in_fd, offset, size); err = sendfile(out_fd, in_fd, offset, size);
if (err < 0) if (err < 0)
return -errno; return -errno;
return err; return err;
} }
#elif HAVE_SENDFILE7_SUPPORT #elif HAVE_SENDFILE7_SUPPORT
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/uio.h> #include <sys/uio.h>
int zm_sendfile(int out_fd, int in_fd, off_t *offset, off_t size) { int zm_sendfile(int out_fd, int in_fd, off_t *offset, off_t size) {
int err; int err;
err = sendfile(in_fd, out_fd, *offset, size, NULL, &size, 0); err = sendfile(in_fd, out_fd, *offset, size, NULL, &size, 0);
if (err && errno != EAGAIN) if (err && errno != EAGAIN)
return -errno; return -errno;
if (size) { if (size) {
*offset += size; *offset += size;
return size; return size;
} }
return -EAGAIN; return -EAGAIN;
} }
#else #else
#error "Your platform does not support sendfile. Sorry." #error "Your platform does not support sendfile. Sorry."