From: Timo Sirainen Date: Thu, 2 Apr 2020 20:38:23 +0000 (+0300) Subject: lib-index: Add mail_cache_purge_drop_field event X-Git-Tag: 2.3.11.2~364 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=63dc8373d20b73b6c6bd8418880ebe38fb7239eb;p=thirdparty%2Fdovecot%2Fcore.git lib-index: Add mail_cache_purge_drop_field event --- diff --git a/src/lib-index/mail-cache-purge.c b/src/lib-index/mail-cache-purge.c index 60925677be..c9af9ba653 100644 --- a/src/lib-index/mail-cache-purge.c +++ b/src/lib-index/mail-cache-purge.c @@ -24,6 +24,19 @@ struct mail_cache_copy_context { bool new_msg; }; +static const char *cache_decision_str(enum mail_cache_decision_type dec) +{ + switch (dec & ~MAIL_CACHE_DECISION_FORCED) { + case MAIL_CACHE_DECISION_NO: + return "no"; + case MAIL_CACHE_DECISION_TEMP: + return "temp"; + case MAIL_CACHE_DECISION_YES: + return "yes"; + } + i_unreached(); +} + static void mail_cache_merge_bitmask(struct mail_cache_copy_context *ctx, const struct mail_cache_iterate_field *field) @@ -227,7 +240,19 @@ mail_cache_copy(struct mail_cache *cache, struct mail_index_transaction *trans, /* if the decision isn't forced and this field hasn't been accessed for a while, drop it */ if ((dec & MAIL_CACHE_DECISION_FORCED) == 0 && - priv->field.last_used < max_drop_time) { + priv->field.last_used < max_drop_time && + dec != MAIL_CACHE_DECISION_NO) { + const char *dec_str = cache_decision_str(dec); + struct event_passthrough *e = + event_create_passthrough(event)-> + set_name("mail_cache_purge_drop_field")-> + add_str("field", priv->field.name)-> + add_str("decision", dec_str)-> + add_int("last_used", priv->field.last_used); + e_debug(e->event(), "Purge dropped field %s " + "(decision=%s, last_used=%"PRIdTIME_T")", + priv->field.name, dec_str, + priv->field.last_used); dec = MAIL_CACHE_DECISION_NO; priv->field.decision = dec; }