From: Timo Sirainen Date: Mon, 28 Jan 2013 11:56:24 +0000 (+0200) Subject: dsync: When syncing locally, mailbox_copy() the mail to attempt a fast copy. X-Git-Tag: 2.2.beta2~174 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5d3d7a0e1e517c6dff9bb1750334c8d9e4dce99;p=thirdparty%2Fdovecot%2Fcore.git dsync: When syncing locally, mailbox_copy() the mail to attempt a fast copy. --- diff --git a/src/doveadm/dsync/dsync-ibc-pipe.c b/src/doveadm/dsync/dsync-ibc-pipe.c index 63b7826800..5b27fed43d 100644 --- a/src/doveadm/dsync/dsync-ibc-pipe.c +++ b/src/doveadm/dsync/dsync-ibc-pipe.c @@ -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 diff --git a/src/doveadm/dsync/dsync-mail.h b/src/doveadm/dsync/dsync-mail.h index ae1a3d3ae9..808790d972 100644 --- a/src/doveadm/dsync/dsync-mail.h +++ b/src/doveadm/dsync/dsync-mail.h @@ -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 { diff --git a/src/doveadm/dsync/dsync-mailbox-export.c b/src/doveadm/dsync/dsync-mailbox-export.c index 47673c1f61..22c9599841 100644 --- a/src/doveadm/dsync/dsync-mailbox-export.c +++ b/src/doveadm/dsync/dsync-mailbox-export.c @@ -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"); diff --git a/src/doveadm/dsync/dsync-mailbox-import.c b/src/doveadm/dsync/dsync-mailbox-import.c index da9c749c1d..95448ef149 100644 --- a/src/doveadm/dsync/dsync-mailbox-import.c +++ b/src/doveadm/dsync/dsync-mailbox-import.c @@ -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;