]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Set mailbox list index to be refreshed after changes, not before
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 6 Jul 2017 14:45:02 +0000 (17:45 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 12 Jul 2017 21:40:11 +0000 (00:40 +0300)
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.

src/lib-storage/list/mailbox-list-index.c

index f1e851f151853d9b374157edce2cbac7b94d6ce8..ac1168e86a2ab9cba3dcae9acb20291ebed2e7bf 100644 (file)
@@ -668,8 +668,10 @@ mailbox_list_index_delete_mailbox(struct mailbox_list *list, const char *name)
 {
        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 @@ mailbox_list_index_delete_dir(struct mailbox_list *list, const char *name)
 {
        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 @@ mailbox_list_index_rename_mailbox(struct mailbox_list *oldlist,
 {
        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