diff src/lib-storage/index/cydir/cydir-save.c @ 5963:9bef18690777 HEAD

Cache updater might not have seen all the input data producing broken data.
author Timo Sirainen <tss@iki.fi>
date Thu, 12 Jul 2007 06:12:44 +0300
parents 6b06a60d7e44
children d911d943438e
line wrap: on
line diff
--- 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 @@
 	if (ctx->failed)
 		return -1;
 
-	index_mail_cache_parse_continue(ctx->cur_dest_mail);
+	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));
+		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;
 		}
-		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;
 }