]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dict: Use dict-init-cache
authorSiavash Tavakoli <siavash.tavakoli@open-xchange.com>
Thu, 1 Jul 2021 12:52:29 +0000 (13:52 +0100)
committersiavash.tavakoli <siavash.tavakoli@open-xchange.com>
Mon, 16 Aug 2021 08:58:47 +0000 (08:58 +0000)
Make use of dict-init-cache for initialization and deinitialization of dicts.

src/dict/dict-connection.c
src/dict/main.c

index d32adc9712e4700732eb523ba18aeb9d7161ffa9..b23272532e55afb078511e2a450952fc183478f3 100644 (file)
@@ -12,6 +12,7 @@
 #include "dict-settings.h"
 #include "dict-commands.h"
 #include "dict-connection.h"
+#include "dict-init-cache.h"
 
 #include <unistd.h>
 
@@ -95,7 +96,7 @@ static int dict_connection_dict_init(struct dict_connection *conn)
        i_zero(&dict_set);
        dict_set.base_dir = dict_settings->base_dir;
        dict_set.event_parent = conn->conn.event;
-       if (dict_init(uri, &dict_set, &conn->dict, &error) < 0) {
+       if (dict_init_cache_get(conn->name, uri, &dict_set, &conn->dict, &error) < 0) {
                /* dictionary initialization failed */
                e_error(conn->conn.event, "Failed to initialize dictionary '%s': %s",
                        conn->name, error);
@@ -162,7 +163,7 @@ bool dict_connection_unref(struct dict_connection *conn)
        }
 
        if (conn->dict != NULL)
-               dict_deinit(&conn->dict);
+               dict_init_cache_unref(&conn->dict);
 
        if (array_is_created(&conn->transactions))
                array_free(&conn->transactions);
index a8ab615002f30a00dd2b937ae151c38d9656de7b..589efc65704ae7df04ef6120550a037bb6da615f 100644 (file)
@@ -17,6 +17,7 @@
 #include "dict-commands.h"
 #include "dict-connection.h"
 #include "dict-settings.h"
+#include "dict-init-cache.h"
 #include "main.h"
 
 #include <math.h>
@@ -168,6 +169,8 @@ int main(int argc, char *argv[])
        master_service_init_finish(master_service);
        master_service_run(master_service, client_connected);
 
+       /* clean up cached dicts */
+       dict_init_cache_destroy_all();
        main_deinit();
        master_service_deinit(&master_service);
         return 0;