From 7d758a6a6842fac6c511039c29d76300e2e21ccd Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Sat, 6 May 2017 20:19:31 +0100 Subject: Enable use of sendfile on FreeBSD --- src/OS/os.c-FreeBSD | 25 +++++++++++++++++++++++++ src/OS/os.c-Linux | 12 ++++++++++++ src/OS/os.h-FreeBSD | 9 +++++++++ src/OS/os.h-Linux | 10 ++++++---- 4 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 src/OS/os.c-FreeBSD (limited to 'src/OS') diff --git a/src/OS/os.c-FreeBSD b/src/OS/os.c-FreeBSD new file mode 100644 index 000000000..a892e5940 --- /dev/null +++ b/src/OS/os.c-FreeBSD @@ -0,0 +1,25 @@ +/************************************************* +* Exim - an Internet mail transport agent * +*************************************************/ + +/* Copyright (c) Jeremy Harris 2017 */ +/* See the file NOTICE for conditions of use and distribution. */ + +/* FreeBSD-specific code. This is concatenated onto the generic +src/os.c file. */ + + +/************* +* Sendfile * +*************/ +#include + +ssize_t +os_sendfile(int out, int in, off_t * off, size_t cnt) +{ +off_t written; +return sendfile(in, out, *off, cnt, NULL, &written, 0) < 0 + ? (ssize_t) -1 : (ssize_t) written; +} + +/* End of os.c-Linux */ diff --git a/src/OS/os.c-Linux b/src/OS/os.c-Linux index 4bca77615..dd65c8b39 100644 --- a/src/OS/os.c-Linux +++ b/src/OS/os.c-Linux @@ -150,4 +150,16 @@ return yield; #endif /* FIND_RUNNING_INTERFACES */ + +/************* +* Sendfile * +*************/ +#include + +ssize_t +os_sendfile(int out, int in, off_t * off, size_t cnt) +{ +return sendfile(out, in, off, cnt); +} + /* End of os.c-Linux */ diff --git a/src/OS/os.h-FreeBSD b/src/OS/os.h-FreeBSD index bf43e0a3c..9b47de3d1 100644 --- a/src/OS/os.h-FreeBSD +++ b/src/OS/os.h-FreeBSD @@ -1,5 +1,7 @@ /* Exim: OS-specific C header file for FreeBSD */ +#include + #define HAVE_BSD_GETLOADAVG #define HAVE_SETCLASSRESOURCES #define HAVE_MMAP @@ -34,4 +36,11 @@ typedef struct flock flock_t; /* for more specific version constraints, include and look at * __FreeBSD_version */ + +/* When using DKIM, setting OS_SENDFILE can increase +performance on outgoing mail a bit. */ + +#define OS_SENDFILE +extern ssize_t os_sendfile(int, int, off_t *, size_t); + /* End */ diff --git a/src/OS/os.h-Linux b/src/OS/os.h-Linux index 3e9303cab..57034649c 100644 --- a/src/OS/os.h-Linux +++ b/src/OS/os.h-Linux @@ -5,6 +5,7 @@ does not pull in . Best to just pull it in now and have done with the issue. */ #include +#include #define CRYPT_H @@ -15,13 +16,14 @@ with the issue. */ #define NO_IP_VAR_H #define SIG_IGN_WORKS -/* When using the DKIM, setting HAVE_LINUX_SENDFILE can increase +/* When using DKIM, setting OS_SENDFILE can increase performance on outgoing mail a bit. Note: With older glibc versions this setting will conflict with the _FILE_OFFSET_BITS=64 setting defined as part of the Linux CFLAGS. As of 2017 those are declared to be too old to build by default. */ -#define HAVE_LINUX_SENDFILE +#define OS_SENDFILE +extern ssize_t os_sendfile(int, int, off_t *, size_t); #define F_FREESP O_TRUNC typedef struct flock flock_t; @@ -30,8 +32,8 @@ typedef struct flock flock_t; #define OS_STRSIGNAL #if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__NetBSD_kernel__) -#define SIOCGIFCONF_GIVES_ADDR -#define HAVE_SYS_MOUNT_H +# define SIOCGIFCONF_GIVES_ADDR +# define HAVE_SYS_MOUNT_H #endif #if defined(__linux__) -- cgit v1.2.3