From: Aki Tuomi Date: Tue, 25 Aug 2020 11:01:24 +0000 (+0300) Subject: quota: Add event support X-Git-Tag: 2.3.13~253 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=25ed309c85dc12b57b20e1d752040627d645cc69;p=thirdparty%2Fdovecot%2Fcore.git quota: Add event support --- diff --git a/src/plugins/quota/quota-private.h b/src/plugins/quota/quota-private.h index af2ccb65d8..665795c74f 100644 --- a/src/plugins/quota/quota-private.h +++ b/src/plugins/quota/quota-private.h @@ -12,6 +12,7 @@ extern unsigned int quota_module_id; struct quota { struct mail_user *user; struct quota_settings *set; + struct event *event; ARRAY(struct quota_root *) roots; ARRAY(struct mail_namespace *) namespaces; @@ -22,6 +23,7 @@ struct quota_settings { pool_t pool; ARRAY(struct quota_root_settings *) root_sets; + struct event *event; enum quota_alloc_result (*test_alloc)( struct quota_transaction_context *ctx, uoff_t size, const char **error_r); diff --git a/src/plugins/quota/quota.c b/src/plugins/quota/quota.c index cc3ea562b9..084849d053 100644 --- a/src/plugins/quota/quota.c +++ b/src/plugins/quota/quota.c @@ -310,6 +310,7 @@ int quota_user_read_settings(struct mail_user *user, pool = pool_alloconly_create("quota settings", 2048); quota_set = p_new(pool, struct quota_settings, 1); quota_set->pool = pool; + quota_set->event = event_create(user->event); quota_set->test_alloc = quota_default_test_alloc; quota_set->debug = user->mail_debug; quota_set->quota_exceeded_msg = @@ -342,6 +343,7 @@ int quota_user_read_settings(struct mail_user *user, &error) < 0) { *error_r = t_strdup_printf("Invalid quota root %s: %s", root_name, error); + event_unref("a_set->event); pool_unref(&pool); return -1; } @@ -350,6 +352,7 @@ int quota_user_read_settings(struct mail_user *user, } if (quota_set->max_mail_size == 0 && array_count("a_set->root_sets) == 0) { + event_unref("a_set->event); pool_unref(&pool); return 0; } @@ -365,6 +368,7 @@ void quota_settings_deinit(struct quota_settings **_quota_set) *_quota_set = NULL; + event_unref("a_set->event); pool_unref("a_set->pool); } @@ -439,6 +443,8 @@ int quota_init(struct quota_settings *quota_set, struct mail_user *user, int ret; quota = i_new(struct quota, 1); + quota->event = event_create(user->event); + event_set_forced_debug(quota->event, quota_set->debug); quota->user = user; quota->set = quota_set; i_array_init("a->roots, 8); @@ -475,6 +481,7 @@ void quota_deinit(struct quota **_quota) array_free("a->roots); array_free("a->namespaces); + event_unref("a->event); i_free(quota); }