[dovecot-cvs] dovecot/src/lib compat.h, 1.28, 1.29 ostream-file.c, 1.52, 1.53

cras at dovecot.org cras at dovecot.org
Tue Sep 27 22:50:01 EEST 2005


Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv8033/lib

Modified Files:
	compat.h ostream-file.c 
Log Message:
Use IOV_MAX instead of UIO_MAXIOV when available.



Index: compat.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/compat.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- compat.h	27 Mar 2005 14:42:20 -0000	1.28
+++ compat.h	27 Sep 2005 19:49:59 -0000	1.29
@@ -93,6 +93,18 @@
 };
 #endif
 
+/* IOV_MAX should be in limits.h nowadays. Linux still (2005) requires
+   defining _XOPEN_SOURCE to get that value. UIO_MAXIOV works with it though,
+   so use it instead. 16 is the lowest acceptable value for all OSes. */
+#ifndef IOV_MAX
+#  include <sys/uio.h>
+#  ifdef UIO_MAXIOV
+#    define IOV_MAX UIO_MAXIOV
+#  else
+#    define IOV_MAX 16
+#  endif
+#endif
+
 #ifndef HAVE_WRITEV
 #  define writev my_writev
 struct iovec;

Index: ostream-file.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/ostream-file.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- ostream-file.c	25 Sep 2005 10:49:03 -0000	1.52
+++ ostream-file.c	27 Sep 2005 19:49:59 -0000	1.53
@@ -17,10 +17,6 @@
 #  include <sys/uio.h>
 #endif
 
-#ifndef UIO_MAXIOV
-#  define UIO_MAXIOV 16
-#endif
-
 /* try to keep the buffer size within 4k..128k. ReiserFS may actually return
    128k as optimal size. */
 #define DEFAULT_OPTIMAL_BLOCK_SIZE 4096
@@ -137,22 +133,22 @@
 		ret = write(fstream->fd, iov->iov_base, iov->iov_len);
 	else {
 		sent = 0;
-		while (iov_size > UIO_MAXIOV) {
+		while (iov_size > IOV_MAX) {
 			size = 0;
-			for (i = 0; i < UIO_MAXIOV; i++)
+			for (i = 0; i < IOV_MAX; i++)
 				size += iov[i].iov_len;
 
 			ret = writev(fstream->fd, (const struct iovec *)iov,
-				     UIO_MAXIOV);
+				     IOV_MAX);
 			if (ret != (ssize_t)size)
 				break;
 
 			sent += ret;
-			iov += UIO_MAXIOV;
-			iov_size -= UIO_MAXIOV;
+			iov += IOV_MAX;
+			iov_size -= IOV_MAX;
 		}
 
-		if (iov_size <= UIO_MAXIOV) {
+		if (iov_size <= IOV_MAX) {
 			ret = writev(fstream->fd, (const struct iovec *)iov,
 				     iov_size);
 		}
@@ -163,6 +159,7 @@
 	if (ret < 0) {
 		if (errno == EAGAIN || errno == EINTR)
 			return 0;
+		if (errno == EINVAL) i_error("o_stream_sendv() -> EINVAL");
 		fstream->ostream.ostream.stream_errno = errno;
 		stream_closed(fstream);
 		return -1;
@@ -285,6 +282,7 @@
 
 	if (offset > OFF_T_MAX) {
 		stream->ostream.stream_errno = EINVAL;
+		i_error("_seek(1) -> EINVAL");
 		return -1;
 	}
 
@@ -293,11 +291,13 @@
 
 	ret = lseek(fstream->fd, (off_t)offset, SEEK_SET);
 	if (ret < 0) {
+		if (errno == EINVAL) i_error("_seek(2) -> EINVAL");
 		stream->ostream.stream_errno = errno;
 		return -1;
 	}
 
 	if (ret != (off_t)offset) {
+		i_error("_seek(3) -> EINVAL");
 		stream->ostream.stream_errno = EINVAL;
 		return -1;
 	}
@@ -507,6 +507,7 @@
 				break;
 			}
 
+			if (errno == EINVAL) i_error("io_stream_sendfile() -> EINVAL");
 			outstream->ostream.stream_errno = errno;
 			if (errno != EINVAL) {
 				/* close only if error wasn't because
@@ -656,6 +657,7 @@
 		ret = write_full(foutstream->fd, data, size);
 		if (ret < 0) {
 			/* error */
+			if (errno == EINVAL) i_error("copy backwards -> EINVAL");
 			outstream->ostream.stream_errno = errno;
 			return -1;
 		}
@@ -674,6 +676,7 @@
 
 	st = i_stream_stat(instream);
 	if (st == NULL) {
+       		if (errno == EINVAL) i_error("_send_istream() / stat -> EINVAL");
 		outstream->ostream.stream_errno = instream->stream_errno;
 		return -1;
 	}
@@ -689,6 +692,7 @@
 		/* copying data within same fd. we'll have to be careful with
 		   seeks and overlapping writes. */
 		if (in_size == (uoff_t)-1) {
+			i_error("_send_istream() / in_size == -1 -> EINVAL");
 			outstream->ostream.stream_errno = EINVAL;
 			return -1;
 		}



More information about the dovecot-cvs mailing list