changeset 7060:72122918288c HEAD

Free mail before committing index sync to avoid crashes when updating cache file.
author Timo Sirainen <tss@iki.fi>
date Sat, 29 Dec 2007 07:22:38 +0200
parents 0a0ff276bc38
children 4ff39d30aa4a
files src/lib-storage/index/maildir/maildir-save.c
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/maildir/maildir-save.c	Sat Dec 29 07:18:44 2007 +0200
+++ b/src/lib-storage/index/maildir/maildir-save.c	Sat Dec 29 07:22:38 2007 +0200
@@ -693,8 +693,16 @@
 	*t->ictx.saved_uid_validity =
 		maildir_uidlist_get_uid_validity(ctx->mbox->uidlist);
 
+	if (ctx->mail != NULL) {
+		/* Mail freeing may trigger cache updates and a call to
+		   maildir_save_file_get_path(). Do this before finishing index
+		   sync so we still have keywords_sync_ctx. */
+		mail_free(&ctx->mail);
+	}
+
 	if (sync_commit) {
 		/* It doesn't matter if index syncing fails */
+		ctx->keywords_sync_ctx = NULL;
 		(void)maildir_sync_index_finish(&ctx->sync_ctx,
 						ret < 0, !sync_commit);
 	}
@@ -715,9 +723,6 @@
 		maildir_transaction_save_rollback(ctx);
 		return -1;
 	}
-
-	if (ctx->mail != NULL)
-		mail_free(&ctx->mail);
 	return ret;
 }