From: Timo Sirainen Date: Mon, 16 Apr 2018 12:22:41 +0000 (+0300) Subject: lib-storage: Add mail_storage.event and use it wherever possible X-Git-Tag: 2.3.3.rc1~214 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=da5f06dd9562572130f2d8c591099b37b4c4ffe8;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Add mail_storage.event and use it wherever possible --- diff --git a/src/lib-storage/index/dbox-multi/mdbox-map.c b/src/lib-storage/index/dbox-multi/mdbox-map.c index 01b37d6ad6..e464f5b086 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-map.c +++ b/src/lib-storage/index/dbox-multi/mdbox-map.c @@ -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, diff --git a/src/lib-storage/index/index-rebuild.c b/src/lib-storage/index/index-rebuild.c index b8963382e1..4727928c80 100644 --- a/src/lib-storage/index/index-rebuild.c +++ b/src/lib-storage/index/index-rebuild.c @@ -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 diff --git a/src/lib-storage/index/index-storage.c b/src/lib-storage/index/index-storage.c index 9889edfafa..6c92832223 100644 --- a/src/lib-storage/index/index-storage.c +++ b/src/lib-storage/index/index-storage.c @@ -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, diff --git a/src/lib-storage/mail-storage-private.h b/src/lib-storage/mail-storage-private.h index 20d22ab3ca..c089659a65 100644 --- a/src/lib-storage/mail-storage-private.h +++ b/src/lib-storage/mail-storage-private.h @@ -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; diff --git a/src/lib-storage/mail-storage.c b/src/lib-storage/mail-storage.c index b17ff61049..c8d76e02a5 100644 --- a/src/lib-storage/mail-storage.c +++ b/src/lib-storage/mail-storage.c @@ -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); diff --git a/src/lib-storage/test-mail-storage.c b/src/lib-storage/test-mail-storage.c index 73169d0e6f..53989bcf2e 100644 --- a/src/lib-storage/test-mail-storage.c +++ b/src/lib-storage/test-mail-storage.c @@ -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); }