dovecot-2.2: dsync: Fixes to handling output stream buffering.

dovecot at dovecot.org dovecot at dovecot.org
Tue Jan 8 07:43:40 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/5bb80a6491eb
changeset: 15594:5bb80a6491eb
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Jan 08 07:43:29 2013 +0200
description:
dsync: Fixes to handling output stream buffering.

diffstat:

 src/doveadm/dsync/dsync-brain-mails.c |  39 ++++++++++++++++------------------
 src/doveadm/dsync/dsync-brain.c       |   2 -
 src/doveadm/dsync/dsync-ibc-pipe.c    |   1 -
 src/doveadm/dsync/dsync-ibc-private.h |   1 -
 src/doveadm/dsync/dsync-ibc-stream.c  |  21 +++---------------
 src/doveadm/dsync/dsync-ibc.c         |   6 -----
 src/doveadm/dsync/dsync-ibc.h         |   1 -
 7 files changed, 22 insertions(+), 49 deletions(-)

diffs (174 lines):

diff -r e0d4d8f9d097 -r 5bb80a6491eb src/doveadm/dsync/dsync-brain-mails.c
--- a/src/doveadm/dsync/dsync-brain-mails.c	Tue Jan 08 07:42:38 2013 +0200
+++ b/src/doveadm/dsync/dsync-brain-mails.c	Tue Jan 08 07:43:29 2013 +0200
@@ -283,31 +283,28 @@
 		break;
 	}
 
-	if (brain->failed)
-		return TRUE;
-
-	switch (brain->box_send_state) {
-	case DSYNC_BOX_STATE_MAILBOX:
-		/* wait for mailbox to be received first */
-		break;
-	case DSYNC_BOX_STATE_CHANGES:
-		dsync_brain_send_mail_change(brain);
-		changed = TRUE;
-		break;
-	case DSYNC_BOX_STATE_MAIL_REQUESTS:
-		if (dsync_brain_send_mail_request(brain))
+	if (!dsync_ibc_is_send_queue_full(brain->ibc) && !brain->failed) {
+		switch (brain->box_send_state) {
+		case DSYNC_BOX_STATE_MAILBOX:
+			/* wait for mailbox to be received first */
+			break;
+		case DSYNC_BOX_STATE_CHANGES:
+			dsync_brain_send_mail_change(brain);
 			changed = TRUE;
-		break;
-	case DSYNC_BOX_STATE_MAILS:
-		if (!dsync_ibc_is_send_queue_full(brain->ibc)) {
+			break;
+		case DSYNC_BOX_STATE_MAIL_REQUESTS:
+			if (dsync_brain_send_mail_request(brain))
+				changed = TRUE;
+			break;
+		case DSYNC_BOX_STATE_MAILS:
 			if (dsync_brain_send_mail(brain))
 				changed = TRUE;
+			break;
+		case DSYNC_BOX_STATE_RECV_LAST_COMMON:
+			i_unreached();
+		case DSYNC_BOX_STATE_DONE:
+			break;
 		}
-		break;
-	case DSYNC_BOX_STATE_RECV_LAST_COMMON:
-		i_unreached();
-	case DSYNC_BOX_STATE_DONE:
-		break;
 	}
 	if (brain->debug) {
 		i_debug("brain %c: out box '%s' recv_state=%s send_state=%s changed=%d",
diff -r e0d4d8f9d097 -r 5bb80a6491eb src/doveadm/dsync/dsync-brain.c
--- a/src/doveadm/dsync/dsync-brain.c	Tue Jan 08 07:42:38 2013 +0200
+++ b/src/doveadm/dsync/dsync-brain.c	Tue Jan 08 07:43:29 2013 +0200
@@ -332,8 +332,6 @@
 	T_BEGIN {
 		ret = dsync_brain_run_real(brain, changed_r);
 	} T_END;
-	if (!brain->failed)
-		dsync_ibc_flush(brain->ibc);
 	return ret;
 }
 
diff -r e0d4d8f9d097 -r 5bb80a6491eb src/doveadm/dsync/dsync-ibc-pipe.c
--- a/src/doveadm/dsync/dsync-ibc-pipe.c	Tue Jan 08 07:42:38 2013 +0200
+++ b/src/doveadm/dsync/dsync-ibc-pipe.c	Tue Jan 08 07:43:29 2013 +0200
@@ -453,7 +453,6 @@
 	dsync_ibc_pipe_recv_mail_request,
 	dsync_ibc_pipe_send_mail,
 	dsync_ibc_pipe_recv_mail,
-	NULL,
 	dsync_ibc_pipe_is_send_queue_full,
 	dsync_ibc_pipe_has_pending_data
 };
diff -r e0d4d8f9d097 -r 5bb80a6491eb src/doveadm/dsync/dsync-ibc-private.h
--- a/src/doveadm/dsync/dsync-ibc-private.h	Tue Jan 08 07:42:38 2013 +0200
+++ b/src/doveadm/dsync/dsync-ibc-private.h	Tue Jan 08 07:43:29 2013 +0200
@@ -61,7 +61,6 @@
 		(*recv_mail)(struct dsync_ibc *ibc,
 			     struct dsync_mail **mail_r);
 
-	void (*flush)(struct dsync_ibc *ibc);
 	bool (*is_send_queue_full)(struct dsync_ibc *ibc);
 	bool (*has_pending_data)(struct dsync_ibc *ibc);
 };
diff -r e0d4d8f9d097 -r 5bb80a6491eb src/doveadm/dsync/dsync-ibc-stream.c
--- a/src/doveadm/dsync/dsync-ibc-stream.c	Tue Jan 08 07:42:38 2013 +0200
+++ b/src/doveadm/dsync/dsync-ibc-stream.c	Tue Jan 08 07:43:29 2013 +0200
@@ -170,7 +170,9 @@
 		if (dsync_ibc_stream_read_mail_stream(ibc) == 0)
 			return;
 	}
+	o_stream_cork(ibc->output);
 	ibc->ibc.io_callback(ibc->ibc.io_context);
+	o_stream_uncork(ibc->output);
 }
 
 static int dsync_ibc_stream_send_mail_stream(struct dsync_ibc_stream *ibc)
@@ -295,8 +297,7 @@
 		}
 	} T_END;
 	o_stream_nsend_str(ibc->output, ".\n");
-
-	dsync_ibc_flush(&ibc->ibc);
+	o_stream_uncork(ibc->output);
 }
 
 static void dsync_ibc_stream_deinit(struct dsync_ibc *_ibc)
@@ -1390,11 +1391,7 @@
 		ibc->mail_output_last = '\0';
 		ibc->mail_output = mail->input;
 		i_stream_ref(ibc->mail_output);
-		if (dsync_ibc_stream_send_mail_stream(ibc) == 0) {
-			/* flush callback isn't being called while output
-			   stream is corked */
-			o_stream_uncork(ibc->output);
-		}
+		(void)dsync_ibc_stream_send_mail_stream(ibc);
 	}
 }
 
@@ -1492,15 +1489,6 @@
 	return DSYNC_IBC_RECV_RET_OK;
 }
 
-static void dsync_ibc_stream_flush(struct dsync_ibc *_ibc)
-{
-	struct dsync_ibc_stream *ibc = (struct dsync_ibc_stream *)_ibc;
-
-	o_stream_uncork(ibc->output);
-	if (ibc->mail_output == NULL)
-		o_stream_cork(ibc->output);
-}
-
 static bool dsync_ibc_stream_is_send_queue_full(struct dsync_ibc *_ibc)
 {
 	struct dsync_ibc_stream *ibc = (struct dsync_ibc_stream *)_ibc;
@@ -1543,7 +1531,6 @@
 	dsync_ibc_stream_recv_mail_request,
 	dsync_ibc_stream_send_mail,
 	dsync_ibc_stream_recv_mail,
-	dsync_ibc_stream_flush,
 	dsync_ibc_stream_is_send_queue_full,
 	dsync_ibc_stream_has_pending_data
 };
diff -r e0d4d8f9d097 -r 5bb80a6491eb src/doveadm/dsync/dsync-ibc.c
--- a/src/doveadm/dsync/dsync-ibc.c	Tue Jan 08 07:42:38 2013 +0200
+++ b/src/doveadm/dsync/dsync-ibc.c	Tue Jan 08 07:43:29 2013 +0200
@@ -178,12 +178,6 @@
 	return ibc->v.recv_mail(ibc, mail_r);
 }
 
-void dsync_ibc_flush(struct dsync_ibc *ibc)
-{
-	if (ibc->v.flush != NULL)
-		ibc->v.flush(ibc);
-}
-
 bool dsync_ibc_has_failed(struct dsync_ibc *ibc)
 {
 	return ibc->failed;
diff -r e0d4d8f9d097 -r 5bb80a6491eb src/doveadm/dsync/dsync-ibc.h
--- a/src/doveadm/dsync/dsync-ibc.h	Tue Jan 08 07:42:38 2013 +0200
+++ b/src/doveadm/dsync/dsync-ibc.h	Tue Jan 08 07:43:29 2013 +0200
@@ -110,7 +110,6 @@
 enum dsync_ibc_recv_ret
 dsync_ibc_recv_mail(struct dsync_ibc *ibc, struct dsync_mail **mail_r);
 
-void dsync_ibc_flush(struct dsync_ibc *ibc);
 bool dsync_ibc_has_failed(struct dsync_ibc *ibc);
 bool dsync_ibc_is_send_queue_full(struct dsync_ibc *ibc);
 bool dsync_ibc_has_pending_data(struct dsync_ibc *ibc);


More information about the dovecot-cvs mailing list