changeset 2035:0e65efd14eda HEAD

Solaris: Move from sendfilev() to sendfile() (was it always there?). Make EAFNOSUPPORT error Linux-compatible EINVAL.
author Timo Sirainen <tss@iki.fi>
date Sat, 22 May 2004 05:16:36 +0300
parents 8078400fe561
children b3a56463c812
files configure.in src/lib/sendfile-util.c
diffstat 2 files changed, 12 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/configure.in	Sat May 22 04:18:17 2004 +0300
+++ b/configure.in	Sat May 22 05:16:36 2004 +0300
@@ -1,7 +1,7 @@
 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
 
@@ -721,10 +721,10 @@
 ])
 
 
-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..
--- a/src/lib/sendfile-util.c	Sat May 22 04:18:17 2004 +0300
+++ b/src/lib/sendfile-util.c	Sat May 22 05:16:36 2004 +0300
@@ -81,15 +81,13 @@
 	}
 }
 
-#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);
@@ -97,19 +95,13 @@
 	/* 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