From: Timo Sirainen Date: Thu, 2 Apr 2020 21:22:45 +0000 (+0300) Subject: lib-index: Add mail_cache_record_corrupted event X-Git-Tag: 2.3.11.2~358 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fded15721a2690c2427377d72dbaccadbd4f78fa;p=thirdparty%2Fdovecot%2Fcore.git lib-index: Add mail_cache_record_corrupted event --- diff --git a/src/lib-index/mail-cache.c b/src/lib-index/mail-cache.c index 4de6aea9dd..c7197cd4b8 100644 --- a/src/lib-index/mail-cache.c +++ b/src/lib-index/mail-cache.c @@ -58,14 +58,10 @@ void mail_cache_set_corrupted(struct mail_cache *cache, const char *fmt, ...) void mail_cache_set_seq_corrupted_reason(struct mail_cache_view *cache_view, uint32_t seq, const char *reason) { - uint32_t empty = 0; + uint32_t uid, empty = 0; struct mail_cache *cache = cache_view->cache; struct mail_index_view *view = cache_view->view; - mail_index_set_error(cache->index, - "Corrupted record in index cache file %s: %s", - cache->filepath, reason); - /* drop cache pointer */ struct mail_index_transaction *t = mail_index_transaction_begin(view, MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL); @@ -76,6 +72,14 @@ void mail_cache_set_seq_corrupted_reason(struct mail_cache_view *cache_view, maybe it works again later. */ return; } + + mail_index_lookup_uid(cache_view->view, seq, &uid); + const char *errstr = t_strdup_printf( + "Deleting corrupted cache record uid=%u: %s", uid, reason); + e_error(event_create_passthrough(cache->event)-> + set_name("mail_cache_record_corrupted")-> + add_int("uid", uid)-> + add_str("reason", reason)->event(), "%s", errstr); mail_cache_expunge_count(cache, 1); }