]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Add mail_storage.event and use it wherever possible
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 16 Apr 2018 12:22:41 +0000 (15:22 +0300)
committerAki Tuomi <aki.tuomi@dovecot.fi>
Tue, 7 Aug 2018 09:51:21 +0000 (12:51 +0300)
src/lib-storage/index/dbox-multi/mdbox-map.c
src/lib-storage/index/index-rebuild.c
src/lib-storage/index/index-storage.c
src/lib-storage/mail-storage-private.h
src/lib-storage/mail-storage.c
src/lib-storage/test-mail-storage.c

index 01b37d6ad605bdc21a0961b47b19f4d0ec6df769..e464f5b086ace630322e9e2f0c277c8b41011d24 100644 (file)
@@ -59,7 +59,7 @@ mdbox_map_init(struct mdbox_storage *storage, struct mailbox_list *root_list)
        map->path = i_strconcat(root, "/"MDBOX_GLOBAL_DIR_NAME, NULL);
        map->index_path =
                i_strconcat(index_root, "/"MDBOX_GLOBAL_DIR_NAME, NULL);
-       map->index = mail_index_alloc(storage->storage.storage.user->event,
+       map->index = mail_index_alloc(storage->storage.storage.event,
                                      map->index_path,
                                      MDBOX_GLOBAL_INDEX_PREFIX);
        mail_index_set_fsync_mode(map->index,
index b8963382e184aeb42047da4fa5c1bf319ee7c7cd..4727928c80c278e5d4f56ce5c8b87b475b398231 100644 (file)
@@ -214,7 +214,7 @@ index_index_rebuild_init(struct mailbox *box, struct mail_index_view *view,
        /* if backup index file exists, try to use it */
        index_dir = mailbox_get_index_path(box);
        backup_path = t_strconcat(box->index_prefix, ".backup", NULL);
-       ctx->backup_index = mail_index_alloc(box->storage->user->event,
+       ctx->backup_index = mail_index_alloc(box->storage->event,
                                             index_dir, backup_path);
 
 #ifndef MMAP_CONFLICTS_WRITE
index 9889edfafa4b8a1a9239e70bc66d34e37697fdbd..6c92832223f54e78a88e6298cbcebb74913e5dba 100644 (file)
@@ -161,7 +161,7 @@ index_mailbox_alloc_index(struct mailbox *box, struct mail_index **index_r)
            mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX,
                                &index_dir) <= 0)
                index_dir = NULL;
-       *index_r = mail_index_alloc_cache_get(box->storage->user->event,
+       *index_r = mail_index_alloc_cache_get(box->storage->event,
                                              mailbox_path, index_dir,
                                              box->index_prefix);
        return 0;
@@ -379,7 +379,7 @@ void index_storage_mailbox_alloc(struct mailbox *box, const char *vname,
                             mailbox_list_get_storage_name(box->list, vname));
        box->flags = flags;
        box->index_prefix = p_strdup(box->pool, index_prefix);
-       box->event = event_create(box->storage->user->event);
+       box->event = event_create(box->storage->event);
        event_add_category(box->event, &event_category_mailbox);
        event_add_str(box->event, "name", box->vname);
        event_set_append_log_prefix(box->event,
index 20d22ab3ca08225c8337f614c4d11ed6aa159bdb..c089659a655270570f0be32ee5ed36827f576062 100644 (file)
@@ -160,6 +160,7 @@ struct mail_storage {
        char *error_string;
        enum mail_error error;
        ARRAY(struct mail_storage_error) error_stack;
+       struct event *event;
 
         const struct mail_storage *storage_class;
        struct mail_user *user;
index b17ff61049b6927c560bae92fdaee0ae8be7fc9f..c8d76e02a5ef3c5087e18ebf571a0b5ce38fe950 100644 (file)
@@ -421,6 +421,7 @@ int mail_storage_create_full(struct mail_namespace *ns, const char *driver,
        storage->user = ns->user;
        storage->set = ns->mail_set;
        storage->flags = flags;
+       storage->event = event_create(ns->user->event);
        p_array_init(&storage->module_contexts, storage->pool, 5);
 
        if (storage->v.create != NULL &&
@@ -480,6 +481,7 @@ void mail_storage_unref(struct mail_storage **_storage)
                i_assert(array_count(&storage->error_stack) == 0);
                array_free(&storage->error_stack);
        }
+       event_unref(&storage->event);
 
        *_storage = NULL;
        pool_unref(&storage->pool);
@@ -559,7 +561,7 @@ void mail_storage_set_critical(struct mail_storage *storage,
        storage->last_internal_error = i_strdup_vprintf(fmt, va);
        va_end(va);
        storage->last_error_is_internal = TRUE;
-       e_error(storage->user->event, "%s", storage->last_internal_error);
+       e_error(storage->event, "%s", storage->last_internal_error);
 
        /* free the old_error and old_internal_error only after the new error
           is generated, because they may be one of the parameters. */
@@ -1378,7 +1380,7 @@ static int mailbox_alloc_index_pvt(struct mailbox *box)
        if (mailbox_create_missing_dir(box, MAILBOX_LIST_PATH_TYPE_INDEX_PRIVATE) < 0)
                return -1;
 
-       box->index_pvt = mail_index_alloc_cache_get(box->storage->user->event,
+       box->index_pvt = mail_index_alloc_cache_get(box->storage->event,
                NULL, index_dir, t_strconcat(box->index_prefix, ".pvt", NULL));
        mail_index_set_fsync_mode(box->index_pvt,
                                  box->storage->set->parsed_fsync_mode, 0);
index 73169d0e6f6172d28a22b87dd4283bcdc90ce75b..53989bcf2e3f634f019d446aa3fc476d2c19aec9 100644 (file)
@@ -9,6 +9,7 @@ static void test_init_storage(struct mail_storage *storage_r)
        i_zero(storage_r);
        storage_r->user = t_new(struct mail_user, 1);
        storage_r->user->event = event_create(NULL);
+       storage_r->event = event_create(storage_r->user->event);
 }
 
 static void test_deinit_storage(struct mail_storage *storage)
@@ -19,6 +20,7 @@ static void test_deinit_storage(struct mail_storage *storage)
                i_assert(array_count(&storage->error_stack) == 0);
                array_free(&storage->error_stack);
        }
+       event_unref(&storage->event);
        event_unref(&storage->user->event);
 }