]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
replication: Don't trigger replication on changes not visible to dsync
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 8 Feb 2018 15:19:24 +0000 (17:19 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Tue, 13 Feb 2018 12:33:12 +0000 (14:33 +0200)
For example if there's a write to .cache file, it doesn't require
replication.

src/plugins/replication/replication-plugin.c

index 461cfeeda3b063a8604519a84852a406a0ff3d95..1fa883cf8d1d60fa834083e37035b5a8f0e82d0d 100644 (file)
@@ -251,6 +251,15 @@ static void replication_mail_copy(void *txn, struct mail *src,
        }
 }
 
+static bool
+replication_want_sync_changes(const struct mail_transaction_commit_changes *changes)
+{
+       /* Replication needs to be triggered on all the user-visible changes,
+          but not e.g. due to writes to cache file. */
+       return (changes->changes_mask &
+               ~MAIL_INDEX_TRANSACTION_CHANGE_OTHERS) != 0;
+}
+
 static void
 replication_mail_transaction_commit(void *txn,
                                    struct mail_transaction_commit_changes *changes)
@@ -262,7 +271,7 @@ replication_mail_transaction_commit(void *txn,
        enum replication_priority priority;
 
        if (ruser != NULL && !ctx->sync_trans &&
-           (ctx->new_messages || changes->changes_mask != 0)) {
+           (ctx->new_messages || replication_want_sync_changes(changes))) {
                priority = !ctx->new_messages ? REPLICATION_PRIORITY_LOW :
                        ruser->sync_secs == 0 ? REPLICATION_PRIORITY_HIGH :
                        REPLICATION_PRIORITY_SYNC;