]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Use new mail_cache_set_seq_corrupted_reason
authorAki Tuomi <aki.tuomi@dovecot.fi>
Tue, 9 May 2017 11:01:07 +0000 (14:01 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Mon, 15 May 2017 12:14:04 +0000 (15:14 +0300)
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

index 5486d31f48ce25d87ac016f22c007eac4804bdf9..471d1d5d0159e1e631489d72b7a2d4b03fe7ece0 100644 (file)
@@ -456,7 +456,7 @@ static bool get_cached_binary_parts(struct index_mail *mail)
        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;
        }
index 961aedcbb2e515461ee59952c32045d7a1b11c70..e491172e14f5e6e6612bfe61903e6551eb0a87d6 100644 (file)
@@ -808,9 +808,8 @@ int index_mail_get_headers(struct mail *_mail, const char *field,
                } 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 @@ int index_mail_get_first_header(struct mail *_mail, const char *field,
                } 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;
index f689c3693ec02243fea002531f313e59c0b4074c..0931bb2eab86951081333a680fad5355670d9f7a 100644 (file)
@@ -105,7 +105,7 @@ static struct message_part *get_unserialized_parts(struct index_mail *mail)
        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 @@ void index_mail_set_cache_corrupted_reason(struct mail *mail,
        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);
 }
index 977e00402e54135e500da7176cddc46fb3b554db..c85fdd95a0401c21f3bcb9e1c35d71c0e0d3b27c 100644 (file)
@@ -346,17 +346,15 @@ maildir_handle_size_caching(struct index_mail *mail, bool quick_check,
                   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;
                }
index 3570606961780802fa80ae8c1590b05a49eac76b..19870c4f52b6a1efa3c432a9402da00e6abe6234 100644 (file)
@@ -738,6 +738,8 @@ void mail_storage_copy_list_error(struct mail_storage *storage,
                                  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);
index a2ee8a0b0c37bbadcc7a5dad0ed1ba532f671a58..835e9d9ea174f9a85f68030dc20a023003d3e623 100644 (file)
@@ -2732,3 +2732,23 @@ int mail_parse_human_timestamp(const char *str, time_t *timestamp_r,
                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);
+}