]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage, plugins/virtual: Use mail_sync_notify()
authorSiavash Tavakoli <siavash.tavakoli@open-xchange.com>
Mon, 29 Mar 2021 12:41:55 +0000 (13:41 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 15 Apr 2021 07:06:27 +0000 (07:06 +0000)
Instead of calling sync_notify vfunc directly.

src/lib-storage/index/dbox-multi/mdbox-sync.c
src/lib-storage/index/dbox-single/sdbox-sync.c
src/lib-storage/index/imapc/imapc-sync.c
src/lib-storage/index/maildir/maildir-sync-index.c
src/lib-storage/index/mbox/mbox-sync.c
src/plugins/virtual/virtual-sync.c

index e41910c955876d03109e6d17b815884cb67b1c8d..595c4d8db70b3a720ac5a21161ed5daf958b45c1 100644 (file)
@@ -122,16 +122,13 @@ static int dbox_sync_mark_expunges(struct mdbox_sync_context *ctx)
        if (mail_index_transaction_commit(&trans) < 0)
                return -1;
 
-       if (box->v.sync_notify != NULL) {
-               /* do notifications after commit finished successfully */
-               box->tmp_sync_view = ctx->sync_view;
-               seq_range_array_iter_init(&iter, &ctx->expunged_seqs); n = 0;
-               while (seq_range_array_iter_nth(&iter, n++, &seq)) {
-                       mail_index_lookup_uid(ctx->sync_view, seq, &uid);
-                       box->v.sync_notify(box, uid, MAILBOX_SYNC_TYPE_EXPUNGE);
-               }
-               box->tmp_sync_view = NULL;
+       box->tmp_sync_view = ctx->sync_view;
+       seq_range_array_iter_init(&iter, &ctx->expunged_seqs); n = 0;
+       while (seq_range_array_iter_nth(&iter, n++, &seq)) {
+               mail_index_lookup_uid(ctx->sync_view, seq, &uid);
+               mailbox_sync_notify(box, uid, MAILBOX_SYNC_TYPE_EXPUNGE);
        }
+       box->tmp_sync_view = NULL;
        return 0;
 }
 
@@ -193,8 +190,7 @@ static int mdbox_sync_index(struct mdbox_sync_context *ctx)
                array_free(&ctx->expunged_seqs);
        }
 
-       if (box->v.sync_notify != NULL)
-               box->v.sync_notify(box, 0, 0);
+       mailbox_sync_notify(box, 0, 0);
 
        return ret == 0 ? 1 :
                (ctx->mbox->storage->corrupted ? 0 : -1);
index acae807041b221e41f03ccb58d3593c8bb466a20..e525895b40e4d10d3003b5d857e86800396e0fd3 100644 (file)
@@ -148,8 +148,8 @@ static void dbox_sync_file_expunge(struct sdbox_sync_context *ctx,
                ret = dbox_file_unlink(file);
 
        /* do sync_notify only when the file was unlinked by us */
-       if (ret > 0 && box->v.sync_notify != NULL)
-               box->v.sync_notify(box, uid, MAILBOX_SYNC_TYPE_EXPUNGE);
+       if (ret > 0)
+               mailbox_sync_notify(box, uid, MAILBOX_SYNC_TYPE_EXPUNGE);
        dbox_file_unref(&file);
 }
 
@@ -163,8 +163,7 @@ static void dbox_sync_expunge_files(struct sdbox_sync_context *ctx)
        array_foreach(&ctx->expunged_uids, uidp) T_BEGIN {
                dbox_sync_file_expunge(ctx, *uidp);
        } T_END;
-       if (ctx->mbox->box.v.sync_notify != NULL)
-               ctx->mbox->box.v.sync_notify(&ctx->mbox->box, 0, 0);
+       mailbox_sync_notify(&ctx->mbox->box, 0, 0);
        ctx->mbox->box.tmp_sync_view = NULL;
 }
 
index 108de4a25a5bbb6cb007399d06de9f87506466d2..76d709a07fac9e88edb206729b29e7904c4eb471 100644 (file)
@@ -421,8 +421,7 @@ static void imapc_sync_index(struct imapc_sync_context *ctx)
        imapc_sync_uid_next(ctx);
        imapc_sync_highestmodseq(ctx);
 
-       if (mbox->box.v.sync_notify != NULL)
-               mbox->box.v.sync_notify(&mbox->box, 0, 0);
+       mailbox_sync_notify(&mbox->box, 0, 0);
 
        if (!ctx->failed) {
                /* reset only after a successful sync */
index d632fb5aa0ff6b29750ed126063b9d7dd0f00416..492d71cd624316d52b2b1a7dcba216c1f9b62dc9 100644 (file)
@@ -86,10 +86,7 @@ static int maildir_expunge(struct maildir_mailbox *mbox, const char *path,
        ctx->expunge_count++;
 
        if (unlink(path) == 0) {
-               if (box->v.sync_notify != NULL) {
-                       box->v.sync_notify(box, ctx->uid,
-                                          MAILBOX_SYNC_TYPE_EXPUNGE);
-               }
+               mailbox_sync_notify(box, ctx->uid, MAILBOX_SYNC_TYPE_EXPUNGE);
                return 1;
        }
        if (errno == ENOENT)
@@ -154,10 +151,7 @@ static int maildir_sync_flags(struct maildir_mailbox *mbox, const char *path,
                        return -1;
                }
        }
-       if (box->v.sync_notify != NULL) {
-               box->v.sync_notify(box, ctx->uid,
-                                  index_sync_type_convert(sync_type));
-       }
+       mailbox_sync_notify(box, ctx->uid, index_sync_type_convert(sync_type));
        return 1;
 }
 
@@ -643,8 +637,7 @@ int maildir_sync_index(struct maildir_index_sync_context *ctx,
                        ret = -1;
        }
 
-       if (mbox->box.v.sync_notify != NULL)
-               mbox->box.v.sync_notify(&mbox->box, 0, 0);
+       mailbox_sync_notify(&mbox->box, 0, 0);
        ctx->mbox->box.tmp_sync_view = NULL;
 
        /* check cur/ mtime later. if we came here from saving messages they
index 32d0cd53d6af0d1de495208745d03e89667a818a..0d2aa7f9a669ca1e2d54aa524f90417bd5f11bce 100644 (file)
@@ -406,8 +406,8 @@ static void mbox_sync_update_flags(struct mbox_sync_mail_context *mail_ctx,
                mail->flags = flags | (mail->flags & MAIL_RECENT) |
                        MAIL_INDEX_MAIL_FLAG_DIRTY;
        }
-       if (sync_type != 0 && box->v.sync_notify != NULL) {
-               box->v.sync_notify(box, mail_ctx->mail.uid,
+       if (sync_type != 0) {
+               mailbox_sync_notify(box, mail_ctx->mail.uid,
                                   index_sync_type_convert(sync_type));
        }
 }
@@ -606,10 +606,8 @@ static void mbox_sync_handle_expunge(struct mbox_sync_mail_context *mail_ctx)
        struct mbox_sync_context *sync_ctx = mail_ctx->sync_ctx;
        struct mailbox *box = &sync_ctx->mbox->box;
 
-       if (box->v.sync_notify != NULL) {
-               box->v.sync_notify(box, mail_ctx->mail.uid,
-                                  MAILBOX_SYNC_TYPE_EXPUNGE);
-       }
+       mailbox_sync_notify(box, mail_ctx->mail.uid,
+                          MAILBOX_SYNC_TYPE_EXPUNGE);
        mail_index_expunge(sync_ctx->t, mail_ctx->mail.idx_seq);
 
        mail_ctx->mail.expunged = TRUE;
@@ -2039,8 +2037,7 @@ int mbox_sync(struct mbox_mailbox *mbox, enum mbox_sync_flags flags)
                }
        }
 
-       if (mbox->box.v.sync_notify != NULL)
-               mbox->box.v.sync_notify(&mbox->box, 0, 0);
+       mailbox_sync_notify(&mbox->box, 0, 0);
        return ret;
 }
 
index f6df7767115141126670f71933a58dc16855cd85..ae66bb8151b2b67829985bf4152dfb79067cf9f9 100644 (file)
@@ -488,8 +488,7 @@ static void virtual_sync_index_finish(struct virtual_sync_context *ctx)
                virtual_sync_ext_header_update(ctx);
        }
 
-       if (box->v.sync_notify != NULL)
-               box->v.sync_notify(box, 0, 0);
+       mailbox_sync_notify(box, 0, 0);
 }
 
 static int virtual_sync_backend_box_init(struct virtual_backend_box *bbox)