]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dsync: Added DSYNC_BRAIN_FLAG_NO_NOTIFY to enable MAILBOX_TRANSACTION_FLAG_NO_NOTIFY
authorTimo Sirainen <tss@iki.fi>
Tue, 20 Oct 2015 12:29:07 +0000 (15:29 +0300)
committerTimo Sirainen <tss@iki.fi>
Tue, 20 Oct 2015 12:29:07 +0000 (15:29 +0300)
It's arguable that this should be enabled by default, but people might like
to keep mail_log notifications for dsync.

src/doveadm/dsync/dsync-brain-mailbox.c
src/doveadm/dsync/dsync-brain-private.h
src/doveadm/dsync/dsync-brain.c
src/doveadm/dsync/dsync-brain.h
src/doveadm/dsync/dsync-ibc-stream.c
src/doveadm/dsync/dsync-mailbox-import.c
src/doveadm/dsync/dsync-mailbox-import.h

index b14bb18740ff83b4e253eaba20343571825c5e78..5cd8eb44c7bab787baf91a59b8ffcba00131f47d 100644 (file)
@@ -216,6 +216,8 @@ dsync_brain_sync_mailbox_init_remote(struct dsync_brain *brain,
        if (brain->local_dsync_box.have_only_guid128 ||
            remote_dsync_box->have_only_guid128)
                import_flags |= DSYNC_MAILBOX_IMPORT_FLAG_MAILS_USE_GUID128;
+       if (brain->no_notify)
+               import_flags |= DSYNC_MAILBOX_IMPORT_FLAG_NO_NOTIFY;
 
        brain->box_importer = brain->backup_send ? NULL :
                dsync_mailbox_import_init(brain->box, brain->virtual_all_box,
index 391df6142cfaac010281737dcd6e697f55ec2f18..a6be2222dd23c8b52d95ec28883fe07c6d0893d8 100644 (file)
@@ -111,6 +111,7 @@ struct dsync_brain {
        unsigned int changes_during_sync:1;
        unsigned int require_full_resync:1;
        unsigned int verbose_proctitle:1;
+       unsigned int no_notify:1;
        unsigned int failed:1;
 };
 
index b89db0e6d74dfece2eb68952393bd9aa18bf2cb0..41657a0f7d1eeae80b92f99ac6a1ac84387939b3 100644 (file)
@@ -142,6 +142,7 @@ dsync_brain_set_flags(struct dsync_brain *brain, enum dsync_brain_flags flags)
                (flags & DSYNC_BRAIN_FLAG_NO_MAIL_PREFETCH) != 0;
        brain->no_mailbox_renames =
                (flags & DSYNC_BRAIN_FLAG_NO_MAILBOX_RENAMES) != 0;
+       brain->no_notify = (flags & DSYNC_BRAIN_FLAG_NO_NOTIFY) != 0;
 }
 
 static void
index 0a8962c39f7bbc71ff61b582dac4c7a317cb1aca..168e92f13815b216803afe06afeaaf7a78f13254 100644 (file)
@@ -30,7 +30,9 @@ enum dsync_brain_flags {
        DSYNC_BRAIN_FLAG_NO_MAIL_PREFETCH       = 0x100,
        /* Disable mailbox renaming logic. This is just a kludge that should
           be removed once the renaming logic has no more bugs.. */
-       DSYNC_BRAIN_FLAG_NO_MAILBOX_RENAMES     = 0x200
+       DSYNC_BRAIN_FLAG_NO_MAILBOX_RENAMES     = 0x200,
+       /* Add MAILBOX_TRANSACTION_FLAG_NO_NOTIFY to transactions. */
+       DSYNC_BRAIN_FLAG_NO_NOTIFY              = 0x400
 };
 
 enum dsync_brain_sync_type {
index f052ce5565353a4b6834eb77230b95751e49bcd9..35b2f6e53c77d043931fd889b7d752023b5561e7 100644 (file)
@@ -76,7 +76,7 @@ static const struct {
                "debug sync_visible_namespaces exclude_mailboxes  "
                "send_mail_requests backup_send backup_recv lock_timeout "
                "no_mail_sync no_mailbox_renames no_backup_overwrite purge_remote "
-               "sync_since_timestamp sync_flags virtual_all_box"
+               "no_notify sync_since_timestamp sync_flags virtual_all_box"
        },
        { .name = "mailbox_state",
          .chr = 'S',
@@ -716,6 +716,8 @@ dsync_ibc_stream_send_handshake(struct dsync_ibc *_ibc,
                dsync_serializer_encode_add(encoder, "no_backup_overwrite", "");
        if ((set->brain_flags & DSYNC_BRAIN_FLAG_PURGE_REMOTE) != 0)
                dsync_serializer_encode_add(encoder, "purge_remote", "");
+       if ((set->brain_flags & DSYNC_BRAIN_FLAG_NO_NOTIFY) != 0)
+               dsync_serializer_encode_add(encoder, "no_notify", "");
 
        dsync_serializer_encode_finish(&encoder, str);
        dsync_ibc_stream_send_string(ibc, str);
@@ -822,6 +824,8 @@ dsync_ibc_stream_recv_handshake(struct dsync_ibc *_ibc,
                set->brain_flags |= DSYNC_BRAIN_FLAG_NO_BACKUP_OVERWRITE;
        if (dsync_deserializer_decode_try(decoder, "purge_remote", &value))
                set->brain_flags |= DSYNC_BRAIN_FLAG_PURGE_REMOTE;
+       if (dsync_deserializer_decode_try(decoder, "no_notify", &value))
+               set->brain_flags |= DSYNC_BRAIN_FLAG_NO_NOTIFY;
 
        *set_r = set;
        return DSYNC_IBC_RECV_RET_OK;
index 2cada697349be93f4b0c08b5b8a7e9a63cb1cc2e..6bb11a70bedda397380edde826b4bc2a79e62366 100644 (file)
@@ -62,6 +62,7 @@ struct dsync_mailbox_importer {
        uint32_t remote_first_recent_uid;
        uint64_t remote_highest_modseq, remote_highest_pvt_modseq;
        time_t sync_since_timestamp;
+       enum mailbox_transaction_flags transaction_flags;
 
        enum mail_flags sync_flag;
        const char *sync_keyword;
@@ -170,12 +171,12 @@ static void
 dsync_mailbox_import_transaction_begin(struct dsync_mailbox_importer *importer)
 {
        const enum mailbox_transaction_flags ext_trans_flags =
-               MAILBOX_TRANSACTION_FLAG_SYNC |
+               importer->transaction_flags |
                MAILBOX_TRANSACTION_FLAG_EXTERNAL |
                MAILBOX_TRANSACTION_FLAG_ASSIGN_UIDS;
 
        importer->trans = mailbox_transaction_begin(importer->box,
-                                               MAILBOX_TRANSACTION_FLAG_SYNC);
+                                                   importer->transaction_flags);
        importer->ext_trans = mailbox_transaction_begin(importer->box,
                                                        ext_trans_flags);
        importer->mail = mail_alloc(importer->trans, 0, NULL);
@@ -227,6 +228,9 @@ dsync_mailbox_import_init(struct mailbox *box,
                else
                        importer->sync_keyword = p_strdup(pool, sync_flag);
        }
+       importer->transaction_flags = MAILBOX_TRANSACTION_FLAG_SYNC;
+       if ((flags & DSYNC_MAILBOX_IMPORT_FLAG_NO_NOTIFY) != 0)
+               importer->transaction_flags |= MAILBOX_TRANSACTION_FLAG_NO_NOTIFY;
 
        hash_table_create(&importer->import_guids, pool, 0, str_hash, strcmp);
        hash_table_create_direct(&importer->import_uids, pool, 0);
@@ -2023,7 +2027,7 @@ dsync_mailbox_import_find_virtual_uids(struct dsync_mailbox_importer *importer)
 
        importer->virtual_trans =
                mailbox_transaction_begin(importer->virtual_all_box,
-                                         MAILBOX_TRANSACTION_FLAG_SYNC);
+                                         importer->transaction_flags);
        search_ctx = mailbox_search_init(importer->virtual_trans, search_args,
                                         NULL, MAIL_FETCH_GUID, NULL);
        mail_search_args_unref(&search_args);
index 30c1ed579c8ab87ec51f7e8baaf05a1972deb669..c4a473720c1b6a67c0b97b6a906db25574556e98 100644 (file)
@@ -9,7 +9,8 @@ enum dsync_mailbox_import_flags {
        DSYNC_MAILBOX_IMPORT_FLAG_REVERT_LOCAL_CHANGES  = 0x04,
        DSYNC_MAILBOX_IMPORT_FLAG_DEBUG                 = 0x08,
        DSYNC_MAILBOX_IMPORT_FLAG_MAILS_HAVE_GUIDS      = 0x10,
-       DSYNC_MAILBOX_IMPORT_FLAG_MAILS_USE_GUID128     = 0x20
+       DSYNC_MAILBOX_IMPORT_FLAG_MAILS_USE_GUID128     = 0x20,
+       DSYNC_MAILBOX_IMPORT_FLAG_NO_NOTIFY             = 0x40
 };
 
 struct mailbox;