dovecot: Cache updater might not have seen all the input data pr...

dovecot at dovecot.org dovecot at dovecot.org
Thu Jul 12 06:15:56 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/9bef18690777
changeset: 5963:9bef18690777
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Jul 12 06:12:44 2007 +0300
description:
Cache updater might not have seen all the input data producing broken data.

diffstat:

2 files changed, 33 insertions(+), 23 deletions(-)
src/lib-storage/index/cydir/cydir-save.c     |   27 ++++++++++++++----------
src/lib-storage/index/maildir/maildir-save.c |   29 +++++++++++++++-----------

diffs (76 lines):

diff -r 3e01ee1a2864 -r 9bef18690777 src/lib-storage/index/cydir/cydir-save.c
--- a/src/lib-storage/index/cydir/cydir-save.c	Thu Jul 12 05:51:03 2007 +0300
+++ b/src/lib-storage/index/cydir/cydir-save.c	Thu Jul 12 06:12:44 2007 +0300
@@ -148,17 +148,22 @@ int cydir_save_continue(struct mail_save
 	if (ctx->failed)
 		return -1;
 
-	index_mail_cache_parse_continue(ctx->cur_dest_mail);
-
-	if (o_stream_send_istream(ctx->output, ctx->input) < 0) {
-		if (!mail_storage_set_error_from_errno(storage)) {
-			mail_storage_set_critical(storage,
-				"o_stream_send_istream(%s) failed: %m",
-				cydir_get_save_path(ctx, ctx->mail_count));
-		}
-		ctx->failed = TRUE;
-		return -1;
-	}
+	do {
+		index_mail_cache_parse_continue(ctx->cur_dest_mail);
+
+		if (o_stream_send_istream(ctx->output, ctx->input) < 0) {
+			if (!mail_storage_set_error_from_errno(storage)) {
+				mail_storage_set_critical(storage,
+					"o_stream_send_istream(%s) failed: %m",
+					cydir_get_save_path(ctx, ctx->mail_count));
+			}
+			ctx->failed = TRUE;
+			return -1;
+		}
+		/* both input and input2 readers may consume data from our
+		   primary input stream. we'll have to handle all the data
+		   here. */
+	} while (i_stream_read(ctx->input2) > 0);
 	return 0;
 }
 
diff -r 3e01ee1a2864 -r 9bef18690777 src/lib-storage/index/maildir/maildir-save.c
--- a/src/lib-storage/index/maildir/maildir-save.c	Thu Jul 12 05:51:03 2007 +0300
+++ b/src/lib-storage/index/maildir/maildir-save.c	Thu Jul 12 06:12:44 2007 +0300
@@ -449,18 +449,23 @@ int maildir_save_continue(struct mail_sa
 	if (ctx->failed)
 		return -1;
 
-	if (ctx->cur_dest_mail != NULL)
-		index_mail_cache_parse_continue(ctx->cur_dest_mail);
-
-	if (o_stream_send_istream(ctx->output, ctx->input) < 0) {
-		if (!mail_storage_set_error_from_errno(storage)) {
-			mail_storage_set_critical(storage,
-				"o_stream_send_istream(%s/%s) failed: %m",
-				ctx->tmpdir, ctx->file_last->basename);
-		}
-		ctx->failed = TRUE;
-		return -1;
-	}
+	do {
+		if (ctx->cur_dest_mail != NULL)
+			index_mail_cache_parse_continue(ctx->cur_dest_mail);
+		if (o_stream_send_istream(ctx->output, ctx->input) < 0) {
+			if (!mail_storage_set_error_from_errno(storage)) {
+				mail_storage_set_critical(storage,
+					"o_stream_send_istream(%s/%s) "
+					"failed: %m",
+					ctx->tmpdir, ctx->file_last->basename);
+			}
+			ctx->failed = TRUE;
+			return -1;
+		}
+		/* both input and input2 readers may consume data from our
+		   primary input stream. we'll have to handle all the data
+		   here. */
+	} while (i_stream_read(ctx->input2) > 0);
 	return 0;
 }
 


More information about the dovecot-cvs mailing list