#include "ioloop.h"
#include "mail-cache-private.h"
+struct event_passthrough *
+mail_cache_decision_changed_event(struct mail_cache *cache, struct event *event,
+ unsigned int field)
+{
+ return event_create_passthrough(event)->
+ set_name("mail_cache_decision_changed")->
+ add_str("field", cache->fields[field].field.name)->
+ add_int("last_used", cache->fields[field].field.last_used);
+}
+
void mail_cache_decision_state_update(struct mail_cache_view *view,
uint32_t seq, unsigned int field)
{
cache->fields[field].field.decision = MAIL_CACHE_DECISION_YES;
cache->fields[field].decision_dirty = TRUE;
cache->field_header_write_pending = TRUE;
+
+ const char *reason = uid < hdr->day_first_uid[7] ?
+ "old_mail" : "unordered_access";
+ struct event_passthrough *e =
+ mail_cache_decision_changed_event(
+ view->cache, view->cache->event, field)->
+ add_str("reason", reason)->
+ add_int("uid", uid)->
+ add_str("old_decision", "temp")->
+ add_str("new_decision", "yes");
+ e_debug(e->event(), "Changing field %s decision temp -> yes (uid=%u)",
+ cache->fields[field].field.name, uid);
} else {
cache->fields[field].uid_highwater = uid;
}
mail_index_lookup_uid(view->view, seq, &uid);
cache->fields[field].uid_highwater = uid;
+
+ struct event_passthrough *e =
+ mail_cache_decision_changed_event(cache, cache->event, field)->
+ add_str("reason", "add")->
+ add_int("uid", uid)->
+ add_str("old_decision", "no")->
+ add_str("new_decision", "temp");
+ e_debug(e->event(), "Adding field %s to cache for the first time (uid=%u)",
+ cache->fields[field].field.name, uid);
}
int mail_cache_decisions_copy(struct mail_cache *src, struct mail_cache *dst)
in the cache file. */
void mail_cache_decision_state_update(struct mail_cache_view *view,
uint32_t seq, unsigned int field);
+struct event_passthrough *
+mail_cache_decision_changed_event(struct mail_cache *cache, struct event *event,
+ unsigned int field);
int mail_cache_expunge_handler(struct mail_index_sync_map_ctx *sync_ctx,
uint32_t seq, const void *data,
struct mail_cache_copy_context {
struct mail_cache *cache;
+ struct event *event;
buffer_t *buffer, *field_seen;
ARRAY(unsigned int) bitmask_pos;
/* change permanent decisions to temporary decisions.
if they're still permanent they'll get updated later. */
field = &cache->fields[i].field;
- if (field->decision == MAIL_CACHE_DECISION_YES)
+ if (field->decision == MAIL_CACHE_DECISION_YES) {
field->decision = MAIL_CACHE_DECISION_TEMP;
+
+ struct event_passthrough *e =
+ mail_cache_decision_changed_event(
+ cache, ctx->event, i)->
+ add_str("reason", "purge")->
+ add_str("old_decision", "yes")->
+ add_str("new_decision", "temp");
+ e_debug(e->event(), "Purge changes field %s "
+ "cache decision yes -> temp "
+ "(last_used=%"PRIdTIME_T")",
+ field->name, field->last_used);
+ }
}
i_assert(j == used_fields_count);
i_zero(&ctx);
ctx.cache = cache;
+ ctx.event = event;
ctx.buffer = buffer_create_dynamic(default_pool, 4096);
ctx.field_seen = buffer_create_dynamic(default_pool, 64);
ctx.field_seen_value = 0;