Mercurial > dovecot > core-2.2
changeset 22034:c68622bea90c
lib-storage: Use new mail_cache_set_seq_corrupted_reason
author | Aki Tuomi <aki.tuomi@dovecot.fi> |
---|---|
date | Tue, 09 May 2017 14:01:07 +0300 |
parents | 03b5a6dfd3ba |
children | 86b3bb91add1 |
files | src/lib-storage/index/index-mail-binary.c src/lib-storage/index/index-mail-headers.c src/lib-storage/index/index-mail.c src/lib-storage/index/maildir/maildir-mail.c src/lib-storage/mail-storage-private.h src/lib-storage/mail-storage.c |
diffstat | 6 files changed, 38 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/index-mail-binary.c Tue May 09 14:00:38 2017 +0300 +++ b/src/lib-storage/index/index-mail-binary.c Tue May 09 14:01:07 2017 +0300 @@ -456,7 +456,7 @@ if (message_binary_part_deserialize(mail->mail.data_pool, part_buf->data, part_buf->used, &mail->data.bin_parts) < 0) { - mail_cache_set_corrupted(mail->mail.mail.box->cache, + mail_set_mail_cache_corrupted(&mail->mail.mail, "Corrupted cached binary.parts data"); return FALSE; }
--- a/src/lib-storage/index/index-mail-headers.c Tue May 09 14:00:38 2017 +0300 +++ b/src/lib-storage/index/index-mail-headers.c Tue May 09 14:01:07 2017 +0300 @@ -808,9 +808,8 @@ } T_END; if (ret < 0 && retry) { - mail_cache_set_corrupted(_mail->box->cache, - "Broken header %s for mail UID %u", - field, _mail->uid); + mail_set_mail_cache_corrupted(_mail, "Broken header %s", + field); } else { break; } @@ -844,9 +843,8 @@ } T_END; if (ret < 0 && retry) { - mail_cache_set_corrupted(_mail->box->cache, - "Broken header %s for mail UID %u", - field, _mail->uid); + mail_set_mail_cache_corrupted(_mail, "Broken header %s", + field); /* retry by parsing the full header */ } else { break;
--- a/src/lib-storage/index/index-mail.c Tue May 09 14:00:38 2017 +0300 +++ b/src/lib-storage/index/index-mail.c Tue May 09 14:01:07 2017 +0300 @@ -105,7 +105,7 @@ parts = message_part_deserialize(mail->mail.data_pool, part_buf->data, part_buf->used, &error); if (parts == NULL) { - mail_cache_set_corrupted(mail->mail.mail.box->cache, + mail_set_mail_cache_corrupted(&mail->mail.mail, "Corrupted cached mime.parts data: %s (parts=%s)", error, binary_to_hex(part_buf->data, part_buf->used)); } @@ -2347,13 +2347,13 @@ imail->data.no_caching = TRUE; imail->data.forced_no_caching = TRUE; if (reason[0] == '\0') { - mail_cache_set_corrupted(mail->box->cache, - "Broken %s for mail UID %u in mailbox %s", - field_name, mail->uid, mail->box->vname); + mail_set_mail_cache_corrupted(mail, + "Broken %s in mailbox %s", + field_name, mail->box->vname); } else { - mail_cache_set_corrupted(mail->box->cache, - "Broken %s for mail UID %u in mailbox %s: %s", - field_name, mail->uid, mail->box->vname, reason); + mail_set_mail_cache_corrupted(mail, + "Broken %s in mailbox %s: %s", + field_name, mail->box->vname, reason); } mail_storage_set_internal_error(mail->box->storage); }
--- a/src/lib-storage/index/maildir/maildir-mail.c Tue May 09 14:00:38 2017 +0300 +++ b/src/lib-storage/index/maildir/maildir-mail.c Tue May 09 14:01:07 2017 +0300 @@ -346,17 +346,15 @@ including to the uidlist if it's already in filename. do some extra checks here to catch potential cache bugs. */ if (vsize && mail->data.virtual_size != size) { - mail_cache_set_corrupted(box->cache, - "Corrupted virtual size for uid=%u: " + mail_set_mail_cache_corrupted(&mail->mail.mail, + "Corrupted virtual size: " "%"PRIuUOFF_T" != %"PRIuUOFF_T, - mail->mail.mail.uid, mail->data.virtual_size, size); mail->data.virtual_size = size; } else if (!vsize && mail->data.physical_size != size) { - mail_cache_set_corrupted(box->cache, - "Corrupted physical size for uid=%u: " + mail_set_mail_cache_corrupted(&mail->mail.mail, + "Corrupted physical size: " "%"PRIuUOFF_T" != %"PRIuUOFF_T, - mail->mail.mail.uid, mail->data.physical_size, size); mail->data.physical_size = size; }
--- a/src/lib-storage/mail-storage-private.h Tue May 09 14:00:38 2017 +0300 +++ b/src/lib-storage/mail-storage-private.h Tue May 09 14:01:07 2017 +0300 @@ -738,6 +738,8 @@ struct mailbox_list *list); void mail_storage_copy_error(struct mail_storage *dest, struct mail_storage *src); +/* set record in mail cache corrupted */ +void mail_set_mail_cache_corrupted(struct mail *mail, const char *fmt, ...); /* Indicate mail being expunged by autoexpunge */ void mail_autoexpunge(struct mail *mail);
--- a/src/lib-storage/mail-storage.c Tue May 09 14:00:38 2017 +0300 +++ b/src/lib-storage/mail-storage.c Tue May 09 14:01:07 2017 +0300 @@ -2732,3 +2732,23 @@ return -1; } } + +void mail_set_mail_cache_corrupted(struct mail *mail, const char *fmt, ...) +{ + struct mail_cache_view *cache_view = + mail->transaction->cache_view; + + i_assert(cache_view != NULL); + + va_list va; + va_start(va, fmt); + + T_BEGIN { + mail_cache_set_seq_corrupted_reason(cache_view, mail->uid, + t_strdup_printf("UID %u: %s", + mail->uid, + t_strdup_vprintf(fmt, va))); + } T_END; + + va_end(va); +}