changeset 4502:0d465504c18a HEAD

When saving a mail with initial keywords, lock the uidlist before doing anything with the file's header.
author Timo Sirainen <tss@iki.fi>
date Mon, 24 Jul 2006 01:40:54 +0300
parents a7178fbf4697
children b7b64b98866b
files src/lib-storage/index/dbox/dbox-save.c
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/dbox/dbox-save.c	Mon Jul 24 00:41:38 2006 +0300
+++ b/src/lib-storage/index/dbox/dbox-save.c	Mon Jul 24 01:40:54 2006 +0300
@@ -154,6 +154,18 @@
 
 	t_push();
 	if (keywords != NULL && keywords->count > 0) {
+		uint32_t uid;
+		time_t mtime;
+
+		/* uidlist must be locked while we're reading or modifying
+		   file's header */
+		if (dbox_uidlist_append_get_first_uid(ctx->append_ctx,
+						      &uid, &mtime) < 0) {
+			ctx->failed = TRUE;
+			t_pop();
+			return -1;
+		}
+
 		/* write keywords to the file */
 		file_keywords = buffer_create_dynamic(pool_datastack_create(),
 						      DBOX_KEYWORD_COUNT);