]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
quota: Add event support
authorAki Tuomi <aki.tuomi@open-xchange.com>
Tue, 25 Aug 2020 11:01:24 +0000 (14:01 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Tue, 8 Sep 2020 18:42:41 +0000 (18:42 +0000)
src/plugins/quota/quota-private.h
src/plugins/quota/quota.c

index af2ccb65d8ecf66be157bf68e6e46ddbf011ca0c..665795c74f31b85175030dae3c68981994f4ae5e 100644 (file)
@@ -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);
index cc3ea562b9555243f798baaf632090728792795a..084849d053d1b1dd878e31f87e599c250fd973f0 100644 (file)
@@ -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(&quota_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(&quota_set->root_sets) == 0) {
+               event_unref(&quota_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(&quota_set->event);
        pool_unref(&quota_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(&quota->roots, 8);
@@ -475,6 +481,7 @@ void quota_deinit(struct quota **_quota)
 
        array_free(&quota->roots);
        array_free(&quota->namespaces);
+       event_unref(&quota->event);
        i_free(quota);
 }