From f1a514c9bfbdb1c67d4d5acbd191f77692e2ecce Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 22 Jun 2010 21:25:39 +0400 Subject: * Darwin sendfile(2) support --- src/buffer.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/buffer.c') diff --git a/src/buffer.c b/src/buffer.c index 6be6ce7d0..be6d2acc8 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -43,10 +43,15 @@ sendfile_callback (rspamd_io_dispatcher_t *d) GError *err; #ifdef HAVE_SENDFILE - #if defined(FREEBSD) || defined(DARWIN) +# if defined(FREEBSD) || defined(DARWIN) + #if defined(FREEBSD) off_t off = 0; /* FreeBSD version */ - if (sendfile (d->sendfile_fd, d->fd, d->offset, 0, 0, &off, 0) != 0) { + if (sendfile (d->sendfile_fd, d->fd, d->offset, 0, NULL, &off, 0) != 0) { + #elif defined(DARWIN) + /* Darwin version */ + if (sendfile (d->sendfile_fd, d->fd, d->offset, &off, NULL, 0) != 0) { + #endif if (errno != EAGAIN) { if (d->err_callback) { err = g_error_new (G_DISPATCHER_ERROR, errno, "%s", strerror (errno)); @@ -75,7 +80,7 @@ sendfile_callback (rspamd_io_dispatcher_t *d) event_add (d->ev, d->tv); d->in_sendfile = FALSE; } - #else +# else /* Linux version */ r = sendfile (d->fd, d->sendfile_fd, &d->offset, d->file_size); if (r == -1) { @@ -113,7 +118,7 @@ sendfile_callback (rspamd_io_dispatcher_t *d) event_add (d->ev, d->tv); d->in_sendfile = FALSE; } - #endif +# endif #else r = write (d->fd, d->map, d->file_size - d->offset); if (r == -1) { -- cgit v1.2.3