AC_INIT(src)
AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(dovecot, 1.0-test9)
+AM_INIT_AUTOMAKE(dovecot, 1.0-test10)
AM_MAINTAINER_MODE
])
-dnl * Solaris compatible sendfilev()
-AC_CHECK_LIB(sendfile, sendfilev, [
+dnl * Solaris compatible sendfile()
+AC_CHECK_LIB(sendfile, sendfile, [
LIBS="$LIBS -lsendfile"
- AC_DEFINE(HAVE_SOLARIS_SENDFILEV,, Define if you have Solaris-compatible sendfilev())
+ AC_DEFINE(HAVE_SOLARIS_SENDFILE,, Define if you have Solaris-compatible sendfile())
], [
dnl * Linux compatible sendfile() - don't check if Solaris one was found.
dnl * This seems to pass with Solaris for some reason..
}
}
-#elif defined (HAVE_SOLARIS_SENDFILEV)
+#elif defined (HAVE_SOLARIS_SENDFILE)
#include <sys/sendfile.h>
#include "network.h"
ssize_t safe_sendfile(int out_fd, int in_fd, uoff_t *offset, size_t count)
{
- struct sendfilevec vec;
- size_t sbytes;
ssize_t ret;
i_assert(count <= SSIZE_T_MAX);
/* NOTE: if outfd is not a socket, some Solaris versions will
kernel panic */
- vec.sfv_fd = in_fd;
- vec.sfv_flag = 0;
- vec.sfv_off = *offset;
- vec.sfv_len = count;
-
- ret = sendfilev(out_fd, &vec, 1, &sbytes);
-
- *offset += sbytes;
-
- if (ret >= 0 || (ret < 0 && errno == EAGAIN && sbytes > 0))
- return (ssize_t)sbytes;
- else
- return -1;
+ ret = sendfile(out_fd, in_fd, offset, count);
+ if (ret < 0 && errno == EAFNOSUPPORT) {
+ /* not supported, return Linux-like EINVAL so caller
+ sees only consistent errnos. */
+ errno = EINVAL;
+ }
+ return ret;
}
#else