changeset 5581:ee2f0f1cd700 HEAD

If we synced the mbox while saving the message (happens only with quota plugin loaded), we could have used a wrong append offset (calculated before sync) which caused "Unexpectedly lost From-line" errors, and depending on the sync either extra NUL lines or Content-Length header written over existing mails (quite unlikely).
author Timo Sirainen <tss@iki.fi>
date Thu, 26 Apr 2007 21:30:19 +0300
parents 071d9bc5a075
children 1c4fd25893bd
files src/lib-storage/index/mbox/mbox-save.c
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/mbox/mbox-save.c	Thu Apr 26 21:26:52 2007 +0300
+++ b/src/lib-storage/index/mbox/mbox-save.c	Thu Apr 26 21:30:19 2007 +0300
@@ -309,12 +309,6 @@
 			   syncing. */
 			mbox_save_init_sync(t);
 		}
-
-		if (mbox_seek_to_end(ctx, &ctx->append_offset) < 0)
-			return -1;
-
-		ctx->output = o_stream_create_file(mbox->mbox_fd, default_pool,
-						   0, FALSE);
 	}
 
 	if (!ctx->synced && want_mail) {
@@ -324,6 +318,14 @@
 		mbox_save_init_sync(t);
 	}
 
+	/* the syncing above could have changed the append offset */
+	if (ctx->append_offset == (uoff_t)-1) {
+		if (mbox_seek_to_end(ctx, &ctx->append_offset) < 0)
+			return -1;
+
+		ctx->output = o_stream_create_file(mbox->mbox_fd, default_pool,
+						   0, FALSE);
+	}
 	return 0;
 }