[dovecot-cvs] dovecot/src/lib-storage/index/mbox istream-raw-mbox.c, 1.16, 1.17 mbox-lock.c, 1.9, 1.10 mbox-save.c, 1.56, 1.57

cras at dovecot.org cras at dovecot.org
Sun Aug 15 06:40:34 EEST 2004


Update of /home/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv20173/lib-storage/index/mbox

Modified Files:
	istream-raw-mbox.c mbox-lock.c mbox-save.c 
Log Message:
We never do blocking reads/writes to network anymore. Changed imap and pop3
processes to use a single I/O loop.

Not much tested yet, and currently LIST/LSUB may eat too much memory and
APPEND eats all CPU.



Index: istream-raw-mbox.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/mbox/istream-raw-mbox.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- istream-raw-mbox.c	26 Jul 2004 14:49:01 -0000	1.16
+++ istream-raw-mbox.c	15 Aug 2004 03:40:32 -0000	1.17
@@ -40,15 +40,6 @@
 	i_stream_set_max_buffer_size(rstream->input, max_size);
 }
 
-static void _set_blocking(struct _iostream *stream, int timeout_msecs,
-			  void (*timeout_cb)(void *), void *context)
-{
-	struct raw_mbox_istream *rstream = (struct raw_mbox_istream *)stream;
-
-	i_stream_set_blocking(rstream->input, timeout_msecs,
-			      timeout_cb, context);
-}
-
 static int mbox_read_from_line(struct raw_mbox_istream *rstream)
 {
 	const unsigned char *buf, *p;
@@ -298,7 +289,6 @@
 	rstream->istream.iostream.close = _close;
 	rstream->istream.iostream.destroy = _destroy;
 	rstream->istream.iostream.set_max_buffer_size = _set_max_buffer_size;
-	rstream->istream.iostream.set_blocking = _set_blocking;
 
 	rstream->istream.read = _read;
 	rstream->istream.seek = _seek;

Index: mbox-lock.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/mbox/mbox-lock.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- mbox-lock.c	20 Jun 2004 11:17:53 -0000	1.9
+++ mbox-lock.c	15 Aug 2004 03:40:32 -0000	1.10
@@ -347,6 +347,7 @@
 {
 	struct flock fl;
 	time_t now;
+	unsigned int next_alarm;
 	int wait_type;
 
 	if (mbox_file_open_latest(ctx, lock_type) < 0)
@@ -361,23 +362,40 @@
 	fl.l_start = 0;
 	fl.l_len = 0;
 
-        wait_type = max_wait_time == 0 ? F_SETLK : F_SETLKW;
+	if (max_wait_time == 0)
+		wait_type = F_SETLK;
+	else {
+		wait_type = F_SETLKW;
+		alarm(I_MIN(max_wait_time, 5));
+	}
+
 	while (fcntl(ctx->ibox->mbox_fd, wait_type, &fl) < 0) {
 		if (errno != EINTR) {
 			if (errno != EAGAIN && errno != EACCES)
 				mbox_set_syscall_error(ctx->ibox, "fcntl()");
+			alarm(0);
 			return -1;
 		}
 
 		now = time(NULL);
-		if (max_wait_time != 0 && now >= max_wait_time)
+		if (max_wait_time != 0 && now >= max_wait_time) {
+			alarm(0);
 			return 0;
+		}
+
+		/* notify locks once every 5 seconds.
+		   try to use rounded values. */
+		next_alarm = (max_wait_time - now) % 5;
+		if (next_alarm == 0)
+			next_alarm = 5;
+		alarm(next_alarm);
 
 		index_storage_lock_notify(ctx->ibox,
 					  MAILBOX_LOCK_NOTIFY_MAILBOX_ABORT,
 					  max_wait_time - now);
 	}
 
+	alarm(0);
 	return 1;
 }
 

Index: mbox-save.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/mbox/mbox-save.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- mbox-save.c	8 Jul 2004 20:26:16 -0000	1.56
+++ mbox-save.c	15 Aug 2004 03:40:32 -0000	1.57
@@ -292,8 +292,7 @@
 			return -1;
 
 		ctx->output = o_stream_create_file(ibox->mbox_fd, default_pool,
-						   4096, FALSE);
-		o_stream_set_blocking(ctx->output, 60000, NULL, NULL);
+						   0, FALSE);
 	}
 
 	if (!ctx->synced && mail_r != NULL) {



More information about the dovecot-cvs mailing list