dovecot-2.2: dsync: saved-date doesn't need to be looked up unti...
dovecot at dovecot.org
dovecot at dovecot.org
Wed Apr 30 03:10:12 UTC 2014
details: http://hg.dovecot.org/dovecot-2.2/rev/99a4788770cb
changeset: 17296:99a4788770cb
user: Timo Sirainen <tss at iki.fi>
date: Wed Apr 30 06:08:46 2014 +0300
description:
dsync: saved-date doesn't need to be looked up until mail body is being read.
This should improve the performance when the saved-date isn't already cached
or otherwise quickly accessible.
This change also makes dsync slightly incompatible with earlier versions.
When using dsync with an earlier version the saved-dates aren't synced. It
would be too much trouble to try to preserve full backwards compatibility,
especially because saved-date doesn't matter so much and isn't even visible
to IMAP clients.
diffstat:
src/doveadm/dsync/dsync-ibc-stream.c | 22 +++++++++++-----------
src/doveadm/dsync/dsync-mail.c | 5 ++++-
src/doveadm/dsync/dsync-mail.h | 3 +--
src/doveadm/dsync/dsync-mailbox-export.c | 11 +++--------
src/doveadm/dsync/dsync-mailbox-import.c | 3 ++-
5 files changed, 21 insertions(+), 23 deletions(-)
diffs (175 lines):
diff -r 494b5e18be58 -r 99a4788770cb src/doveadm/dsync/dsync-ibc-stream.c
--- a/src/doveadm/dsync/dsync-ibc-stream.c Wed Apr 30 06:03:56 2014 +0300
+++ b/src/doveadm/dsync/dsync-ibc-stream.c Wed Apr 30 06:08:46 2014 +0300
@@ -109,7 +109,7 @@
{ .name = "mail_change",
.chr = 'C',
.required_keys = "type uid",
- .optional_keys = "guid hdr_hash modseq pvt_modseq save_timestamp "
+ .optional_keys = "guid hdr_hash modseq pvt_modseq "
"add_flags remove_flags final_flags "
"keywords_reset keyword_changes"
},
@@ -119,7 +119,7 @@
},
{ .name = "mail",
.chr = 'M',
- .optional_keys = "guid uid pop3_uidl pop3_order received_date stream"
+ .optional_keys = "guid uid pop3_uidl pop3_order received_date saved_date stream"
},
{ .name = "mailbox_cache_field",
.chr = 'c',
@@ -1508,10 +1508,6 @@
dsync_serializer_encode_add(encoder, "pvt_modseq",
dec2str(change->pvt_modseq));
}
- if (change->save_timestamp != 0) {
- dsync_serializer_encode_add(encoder, "save_timestamp",
- dec2str(change->save_timestamp));
- }
if (change->add_flags != 0) {
dsync_serializer_encode_add(encoder, "add_flags",
t_strdup_printf("%x", change->add_flags));
@@ -1601,11 +1597,6 @@
dsync_ibc_input_error(ibc, decoder, "Invalid pvt_modseq");
return DSYNC_IBC_RECV_RET_TRYAGAIN;
}
- if (dsync_deserializer_decode_try(decoder, "save_timestamp", &value) &&
- str_to_time(value, &change->save_timestamp) < 0) {
- dsync_ibc_input_error(ibc, decoder, "Invalid save_timestamp");
- return DSYNC_IBC_RECV_RET_TRYAGAIN;
- }
if (dsync_deserializer_decode_try(decoder, "add_flags", &value))
change->add_flags = strtoul(value, NULL, 16);
@@ -1709,6 +1700,10 @@
dsync_serializer_encode_add(encoder, "received_date",
dec2str(mail->received_date));
}
+ if (mail->saved_date != 0) {
+ dsync_serializer_encode_add(encoder, "saved_date",
+ dec2str(mail->saved_date));
+ }
if (mail->input != NULL)
dsync_serializer_encode_add(encoder, "stream", "");
@@ -1770,6 +1765,11 @@
dsync_ibc_input_error(ibc, decoder, "Invalid received_date");
return DSYNC_IBC_RECV_RET_TRYAGAIN;
}
+ if (dsync_deserializer_decode_try(decoder, "saved_date", &value) &&
+ str_to_time(value, &mail->saved_date) < 0) {
+ dsync_ibc_input_error(ibc, decoder, "Invalid saved_date");
+ return DSYNC_IBC_RECV_RET_TRYAGAIN;
+ }
if (dsync_deserializer_decode_try(decoder, "stream", &value)) {
mail->input = dsync_ibc_stream_input_stream(ibc);
if (dsync_ibc_stream_read_mail_stream(ibc) <= 0) {
diff -r 494b5e18be58 -r 99a4788770cb src/doveadm/dsync/dsync-mail.c
--- a/src/doveadm/dsync/dsync-mail.c Wed Apr 30 06:03:56 2014 +0300
+++ b/src/doveadm/dsync/dsync-mail.c Wed Apr 30 06:08:46 2014 +0300
@@ -97,6 +97,10 @@
*error_field_r = "received-date";
return -1;
}
+ if (mail_get_save_date(mail, &dmail_r->saved_date) < 0) {
+ *error_field_r = "saved-date";
+ return -1;
+ }
return 0;
}
@@ -133,7 +137,6 @@
dest_r->hdr_hash = p_strdup(pool, src->hdr_hash);
dest_r->modseq = src->modseq;
dest_r->pvt_modseq = src->pvt_modseq;
- dest_r->save_timestamp = src->save_timestamp;
dest_r->add_flags = src->add_flags;
dest_r->remove_flags = src->remove_flags;
diff -r 494b5e18be58 -r 99a4788770cb src/doveadm/dsync/dsync-mail.h
--- a/src/doveadm/dsync/dsync-mail.h Wed Apr 30 06:03:56 2014 +0300
+++ b/src/doveadm/dsync/dsync-mail.h Wed Apr 30 06:08:46 2014 +0300
@@ -14,6 +14,7 @@
const char *pop3_uidl;
unsigned int pop3_order;
time_t received_date;
+ time_t saved_date;
/* Input stream containing the message text, or NULL if all instances
of the message were already expunged from this mailbox. */
@@ -60,8 +61,6 @@
/* Message's current private modseq (for private flags in
shared mailboxes, otherwise 0) */
uint64_t pvt_modseq;
- /* Message's save timestamp (saves) */
- time_t save_timestamp;
/* List of flag/keyword changes: (saves, flag changes) */
diff -r 494b5e18be58 -r 99a4788770cb src/doveadm/dsync/dsync-mailbox-export.c
--- a/src/doveadm/dsync/dsync-mailbox-export.c Wed Apr 30 06:03:56 2014 +0300
+++ b/src/doveadm/dsync/dsync-mailbox-export.c Wed Apr 30 06:08:46 2014 +0300
@@ -270,24 +270,18 @@
{
struct dsync_mail_change *change;
const char *guid, *hdr_hash;
- time_t save_timestamp;
int ret;
/* update wanted fields in case we didn't already set them for the
search */
- mail_add_temp_wanted_fields(mail, MAIL_FETCH_GUID |
- MAIL_FETCH_SAVE_DATE,
+ mail_add_temp_wanted_fields(mail, MAIL_FETCH_GUID,
exporter->wanted_headers);
/* If message is already expunged here, just skip it */
if ((ret = exporter_get_guids(exporter, mail, &guid, &hdr_hash)) <= 0)
return ret;
- if (mail_get_save_date(mail, &save_timestamp) < 0)
- return dsync_mail_error(exporter, mail, "save-date");
change = export_save_change_get(exporter, mail->uid);
- change->save_timestamp = save_timestamp;
-
change->guid = *guid == '\0' ? "" :
p_strdup(exporter->pool, guid);
change->hdr_hash = p_strdup(exporter->pool, hdr_hash);
@@ -364,7 +358,7 @@
if (exporter->last_common_uid == 0) {
/* we're syncing all mails, so we can request the wanted
fields for all the mails */
- wanted_fields = MAIL_FETCH_GUID | MAIL_FETCH_SAVE_DATE;
+ wanted_fields = MAIL_FETCH_GUID;
wanted_headers = exporter->wanted_headers;
}
@@ -727,6 +721,7 @@
MAIL_FETCH_UIDL_BACKEND |
MAIL_FETCH_POP3_ORDER |
MAIL_FETCH_RECEIVED_DATE |
+ MAIL_FETCH_SAVE_DATE |
MAIL_FETCH_STREAM_HEADER |
MAIL_FETCH_STREAM_BODY, NULL);
mail_search_args_unref(&search_args);
diff -r 494b5e18be58 -r 99a4788770cb src/doveadm/dsync/dsync-mailbox-import.c
--- a/src/doveadm/dsync/dsync-mailbox-import.c Wed Apr 30 06:03:56 2014 +0300
+++ b/src/doveadm/dsync/dsync-mailbox-import.c Wed Apr 30 06:08:46 2014 +0300
@@ -1872,7 +1872,6 @@
if (keywords != NULL)
mailbox_keywords_unref(&keywords);
- mailbox_save_set_save_date(save_ctx, change->save_timestamp);
if (change->modseq > 1) {
(void)mailbox_enable(importer->box, MAILBOX_FEATURE_CONDSTORE);
mailbox_save_set_min_modseq(save_ctx, change->modseq);
@@ -1915,6 +1914,8 @@
mailbox_save_set_uid(save_ctx, newmail->final_uid);
if (*mail->guid != '\0')
mailbox_save_set_guid(save_ctx, mail->guid);
+ if (mail->saved_date != 0)
+ mailbox_save_set_save_date(save_ctx, mail->saved_date);
dsync_mailbox_save_set_metadata(importer, save_ctx, newmail->change);
if (mail->pop3_uidl != NULL && *mail->pop3_uidl != '\0')
mailbox_save_set_pop3_uidl(save_ctx, mail->pop3_uidl);
More information about the dovecot-cvs
mailing list