[dovecot-cvs] dovecot/src/lib ostream-file.c,1.28,1.29
cras at dovecot.org
cras at dovecot.org
Sun Aug 22 07:51:52 EEST 2004
- Previous message: [dovecot-cvs]
dovecot/src/lib-storage/index/mbox istream-raw-mbox.c, 1.17,
1.18 istream-raw-mbox.h, 1.6, 1.7 mbox-sync.c, 1.66, 1.67
- Next message: [dovecot-cvs]
dovecot/src/lib Makefile.am, 1.40, 1.41 ostream-crlf.c,
NONE, 1.1 ostream-crlf.h, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv30071
Modified Files:
ostream-file.c
Log Message:
Limit iovec count to UIO_MAXIOV for writev() calls.
Index: ostream-file.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/ostream-file.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- ostream-file.c 15 Aug 2004 03:40:31 -0000 1.28
+++ ostream-file.c 22 Aug 2004 04:51:50 -0000 1.29
@@ -17,6 +17,10 @@
# 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
@@ -129,11 +133,31 @@
const struct const_iovec *iov, int iov_size)
{
ssize_t ret;
+ size_t size;
+ int i;
if (iov_size == 1)
ret = write(fstream->fd, iov->iov_base, iov->iov_len);
- else
- ret = writev(fstream->fd, (const struct iovec *)iov, iov_size);
+ else {
+ while (iov_size > UIO_MAXIOV) {
+ size = 0;
+ for (i = 0; i < UIO_MAXIOV; i++)
+ size += iov[i].iov_len;
+
+ ret = writev(fstream->fd, (const struct iovec *)iov,
+ UIO_MAXIOV);
+ if (ret != (ssize_t)size)
+ break;
+
+ iov += UIO_MAXIOV;
+ iov_size -= UIO_MAXIOV;
+ }
+
+ if (iov_size <= UIO_MAXIOV) {
+ ret = writev(fstream->fd, (const struct iovec *)iov,
+ iov_size);
+ }
+ }
if (ret < 0) {
if (errno == EAGAIN || errno == EINTR)
- Previous message: [dovecot-cvs]
dovecot/src/lib-storage/index/mbox istream-raw-mbox.c, 1.17,
1.18 istream-raw-mbox.h, 1.6, 1.7 mbox-sync.c, 1.66, 1.67
- Next message: [dovecot-cvs]
dovecot/src/lib Makefile.am, 1.40, 1.41 ostream-crlf.c,
NONE, 1.1 ostream-crlf.h, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list