]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
quota-clone: Code cleanup - moved recursion check to quota_clone_flush()
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 21 Nov 2016 12:02:11 +0000 (14:02 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 22 Nov 2016 09:01:04 +0000 (11:01 +0200)
src/plugins/quota-clone/quota-clone-plugin.c

index e2b5b760abcf56234e105eee3f38422b04b5762f..94cddb7618b00e4d27d9cfedc8cd58bd2bb2c8d6 100644 (file)
@@ -32,7 +32,7 @@ struct quota_clone_mailbox {
        bool quota_changed;
 };
 
-static void quota_clone_flush(struct mailbox *box)
+static void quota_clone_flush_real(struct mailbox *box)
 {
        struct quota_clone_mailbox *qbox = QUOTA_CLONE_CONTEXT(box);
        struct quota_clone_user *quser =
@@ -76,6 +76,21 @@ static void quota_clone_flush(struct mailbox *box)
                qbox->quota_changed = FALSE;
 }
 
+static void quota_clone_flush(struct mailbox *box)
+{
+       struct quota_clone_mailbox *qbox = QUOTA_CLONE_CONTEXT(box);
+       struct quota_clone_user *quser =
+               QUOTA_CLONE_USER_CONTEXT(box->storage->user);
+
+       if (quser->quota_flushing) {
+               /* recursing back from quota recalculation */
+       } else if (qbox->quota_changed) {
+               quser->quota_flushing = TRUE;
+               quota_clone_flush_real(box);
+               quser->quota_flushing = FALSE;
+       }
+}
+
 static int quota_clone_save_finish(struct mail_save_context *ctx)
 {
        struct quota_clone_mailbox *qbox =
@@ -111,18 +126,10 @@ quota_clone_mailbox_sync_notify(struct mailbox *box, uint32_t uid,
 static void quota_clone_mailbox_close(struct mailbox *box)
 {
        struct quota_clone_mailbox *qbox = QUOTA_CLONE_CONTEXT(box);
-       struct quota_clone_user *quser =
-               QUOTA_CLONE_USER_CONTEXT(box->storage->user);
 
        qbox->module_ctx.super.close(box);
 
-       if (quser->quota_flushing) {
-               /* recursing back from quota recalculation */
-       } else if (qbox->quota_changed) {
-               quser->quota_flushing = TRUE;
-               quota_clone_flush(box);
-               quser->quota_flushing = FALSE;
-       }
+       quota_clone_flush(box);
 }
 
 static void quota_clone_mailbox_allocated(struct mailbox *box)