]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lazy-expunge: Handle mailbox create race conditions.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 5 May 2016 15:10:46 +0000 (18:10 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 5 May 2016 15:10:46 +0000 (18:10 +0300)
Don't log an error if another process just created the lazy-expunge mailbox.

src/plugins/lazy-expunge/lazy-expunge-plugin.c

index c8efa184634f5df61e1aa8f148091fbca30b521b..92e2593ea19f9cc1d1757817148b5ebdf160280c 100644 (file)
@@ -125,13 +125,19 @@ mailbox_open_or_create(struct mailbox_list *list, struct mailbox *src_box,
        }
 
        /* try creating and re-opening it. */
-       if (mailbox_create(box, NULL, FALSE) < 0 ||
-           mailbox_open(box) < 0) {
+       if (mailbox_create(box, NULL, FALSE) < 0 &&
+           mailbox_get_last_mail_error(box) != MAIL_ERROR_EXISTS) {
                *error_r = t_strdup_printf("Failed to create mailbox %s: %s", name,
                                           mailbox_get_last_error(box, NULL));
                mailbox_free(&box);
                return NULL;
        }
+       if (mailbox_open(box) < 0) {
+               *error_r = t_strdup_printf("Failed to open created mailbox %s: %s", name,
+                                          mailbox_get_last_error(box, NULL));
+               mailbox_free(&box);
+               return NULL;
+       }
        return box;
 }