]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dsync: When syncing locally, mailbox_copy() the mail to attempt a fast copy.
authorTimo Sirainen <tss@iki.fi>
Mon, 28 Jan 2013 11:56:24 +0000 (13:56 +0200)
committerTimo Sirainen <tss@iki.fi>
Mon, 28 Jan 2013 11:56:24 +0000 (13:56 +0200)
src/doveadm/dsync/dsync-ibc-pipe.c
src/doveadm/dsync/dsync-mail.h
src/doveadm/dsync/dsync-mailbox-export.c
src/doveadm/dsync/dsync-mailbox-import.c

index 63b7826800151471f05e0b3d02cc5a55da69708a..5b27fed43db16eb4a3622a7c2fa5fd44a68fbb2f 100644 (file)
@@ -416,6 +416,8 @@ dsync_ibc_pipe_send_mail(struct dsync_ibc *ibc, const struct dsync_mail *mail)
                item->u.mail.input = mail->input;
                i_stream_ref(mail->input);
        }
+       item->u.mail.input_mail = mail->input_mail;
+       item->u.mail.input_mail_uid = mail->input_mail_uid;
 }
 
 static enum dsync_ibc_recv_ret
index ae1a3d3ae9bc009f36602750b8fde4937563ddfa..808790d9727242cf15438e3db728e73d1596018d 100644 (file)
@@ -17,6 +17,12 @@ struct dsync_mail {
        /* Input stream containing the message text, or NULL if all instances
           of the message were already expunged from this mailbox. */
        struct istream *input;
+
+       /* If non-NULL, we're syncing within the dsync process using ibc-pipe.
+          This mail can be used to mailbox_copy() the mail. */
+       struct mail *input_mail;
+       /* Verify that this equals to input_mail->uid */
+       uint32_t input_mail_uid;
 };
 
 struct dsync_mail_request {
index 47673c1f61a92ca8ac2a76fddb2f23e800dab566..22c9599841b55c344d3f6ab3f18509dc1352658b 100644 (file)
@@ -581,6 +581,8 @@ static int dsync_mailbox_export_mail(struct dsync_mailbox_exporter *exporter,
                return -1;
        }
 
+       dmail->input_mail = mail;
+       dmail->input_mail_uid = mail->uid;
        if (mail_get_stream(mail, NULL, NULL, &dmail->input) < 0)
                return dsync_mail_error(exporter, mail, "body");
 
index da9c749c1d8fe9294f0e74a4757b6e29736797ad..95448ef149447aad6ac88dc2dbdc489a121299bf 100644 (file)
@@ -1317,6 +1317,17 @@ static void dsync_mailbox_save_body(struct dsync_mailbox_importer *importer,
                if (save_ctx == NULL)
                        save_ctx = dsync_mailbox_save_init(importer, mail, newmail);
        }
+       if (ret <= 0 && mail->input_mail != NULL) {
+               /* copy using the source mail */
+               i_assert(mail->input_mail->uid == mail->input_mail_uid);
+               if (mailbox_copy(&save_ctx, mail->input_mail) == 0)
+                       ret = 1;
+               else {
+                       ret = -1;
+                       save_ctx = dsync_mailbox_save_init(importer, mail, newmail);
+               }
+
+       }
        if (ret > 0) {
                array_append(&importer->wanted_uids, &newmail->uid, 1);
                return;