]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Add mail_cache.event with a log prefix and mail-cache category
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 2 Apr 2020 20:25:59 +0000 (23:25 +0300)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 15 Apr 2020 09:41:43 +0000 (12:41 +0300)
src/lib-index/mail-cache-private.h
src/lib-index/mail-cache.c

index 7e127d68cb015a23ceef660b41a0e003d386c23a..69ed818660444532831631c02daf25f4982de137 100644 (file)
@@ -87,6 +87,7 @@ struct mail_cache_field_private {
 
 struct mail_cache {
        struct mail_index *index;
+       struct event *event;
        uint32_t ext_id;
 
        char *filepath;
index 09f035e13bd66f3f5d7615d72943f8271a2260be..8afb3e9616718cfe5038bbe038aa99a417a1d779 100644 (file)
 
 #define MAIL_CACHE_MIN_HEADER_READ_SIZE 4096
 
+static struct event_category event_category_mail_cache = {
+       .name = "mail-cache",
+};
+
 void mail_cache_set_syscall_error(struct mail_cache *cache,
                                  const char *function)
 {
@@ -558,6 +562,11 @@ mail_cache_open_or_create_path(struct mail_index *index, const char *path)
        hash_table_create(&cache->field_name_hash, cache->field_pool, 0,
                          strcase_hash, strcasecmp);
 
+       cache->event = event_create(index->event);
+       event_add_category(cache->event, &event_category_mail_cache);
+       event_set_append_log_prefix(cache->event,
+               t_strdup_printf("Cache %s: ", cache->filepath));
+
        cache->dotlock_settings.use_excl_lock =
                (index->flags & MAIL_INDEX_OPEN_FLAG_DOTLOCK_USE_EXCL) != 0;
        cache->dotlock_settings.nfs_flush =
@@ -604,6 +613,7 @@ void mail_cache_free(struct mail_cache **_cache)
        buffer_free(&cache->read_buf);
        hash_table_destroy(&cache->field_name_hash);
        pool_unref(&cache->field_pool);
+       event_unref(&cache->event);
        i_free(cache->field_file_map);
        i_free(cache->file_field_map);
        i_free(cache->fields);