changeset 22317:a6ffa40d1c9e

lib-storage: Set mailbox list index to be refreshed after changes, not before Mailbox deletion and rename set the refresh-flag before the change was done. This was unnecessary if the change didn't happen. Also there was a race condition that another process could have done the refresh before the change was even done.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Thu, 06 Jul 2017 17:45:02 +0300
parents 884f3c20ff34
children 8d4bf24c6cbc
files src/lib-storage/list/mailbox-list-index.c
diffstat 1 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/list/mailbox-list-index.c	Thu Jul 06 17:36:28 2017 +0300
+++ b/src/lib-storage/list/mailbox-list-index.c	Thu Jul 06 17:45:02 2017 +0300
@@ -668,8 +668,10 @@
 {
 	struct mailbox_list_index *ilist = INDEX_LIST_CONTEXT(list);
 
+	if (ilist->module_ctx.super.delete_mailbox(list, name) < 0)
+		return -1;
 	mailbox_list_index_refresh_later(list);
-	return ilist->module_ctx.super.delete_mailbox(list, name);
+	return 0;
 }
 
 static int
@@ -677,8 +679,10 @@
 {
 	struct mailbox_list_index *ilist = INDEX_LIST_CONTEXT(list);
 
+	if (ilist->module_ctx.super.delete_dir(list, name) < 0)
+		return -1;
 	mailbox_list_index_refresh_later(list);
-	return ilist->module_ctx.super.delete_dir(list, name);
+	return 0;
 }
 
 static int
@@ -689,11 +693,14 @@
 {
 	struct mailbox_list_index *oldilist = INDEX_LIST_CONTEXT(oldlist);
 
+	if (oldilist->module_ctx.super.rename_mailbox(oldlist, oldname,
+						      newlist, newname) < 0)
+		return -1;
+
 	mailbox_list_index_refresh_later(oldlist);
 	if (oldlist != newlist)
 		mailbox_list_index_refresh_later(newlist);
-	return oldilist->module_ctx.super.
-		rename_mailbox(oldlist, oldname, newlist, newname);
+	return 0;
 }
 
 static int