[dovecot-cvs] dovecot/src/lib sendfile-util.c,1.8,1.9

cras at procontrol.fi cras at procontrol.fi
Sat May 22 05:16:38 EEST 2004


Update of /home/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv12905/src/lib

Modified Files:
	sendfile-util.c 
Log Message:
Solaris: Move from sendfilev() to sendfile() (was it always there?). Make
EAFNOSUPPORT error Linux-compatible EINVAL.



Index: sendfile-util.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/sendfile-util.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- a/sendfile-util.c	26 Aug 2003 21:18:16 -0000	1.8
+++ b/sendfile-util.c	22 May 2004 02:16:36 -0000	1.9
@@ -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



More information about the dovecot-cvs mailing list