]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dict: Wait for all dicts to finish pending operations at shutdown
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 22 Sep 2021 17:57:06 +0000 (20:57 +0300)
committerSiavash Tavakoli <siavash.tavakoli@open-xchange.com>
Wed, 29 Sep 2021 08:46:27 +0000 (09:46 +0100)
This also changes the dict process to exit cleanly instead of early via
lib_exit().

src/dict/dict-init-cache.c
src/dict/dict-init-cache.h
src/dict/main.c

index 0e47e2ba16baa144f91a1fc7d65a3a2257e2d66a..ed76940b04df2de58eb31c12761f201cf5dfbb85 100644 (file)
@@ -148,6 +148,14 @@ void dict_init_cache_unref(struct dict **_dict)
        }
 }
 
+void dict_init_cache_wait_all(void)
+{
+       struct dict_init_cache_list *listp;
+
+       for (listp = dicts; listp != NULL; listp = listp->next)
+               dict_wait(listp->dict);
+}
+
 void dict_init_cache_destroy_all(void)
 {
        timeout_remove(&to_dict);
index e26944af9d16afe4c3e7328195bb1ea72ad62e7b..1342ca32e0153d40a5db30d16006b2e8054cc507 100644 (file)
@@ -5,6 +5,8 @@ int dict_init_cache_get(const char *dict_name, const char *uri,
                        const struct dict_settings *set,
                        struct dict **dict_r, const char **error_r);
 void dict_init_cache_unref(struct dict **dict);
+
+void dict_init_cache_wait_all(void);
 void dict_init_cache_destroy_all(void);
 
 #endif
index 589efc65704ae7df04ef6120550a037bb6da615f..3d9185413786e3b95062925111f4122e4b95faad 100644 (file)
@@ -129,12 +129,14 @@ static void main_init(void)
 
 static void main_deinit(void)
 {
-       /* FIXME: we're not able to do a clean deinit currently without
-          larger changes. */
-       lib_exit(0);
        timeout_remove(&to_proctitle);
 
+       /* wait for all dict operations to finish */
+       dict_init_cache_wait_all();
+       /* connections should no longer have any extra refcounts */
        dict_connections_destroy_all();
+       dict_init_cache_destroy_all();
+
        dict_drivers_unregister_all();
        dict_commands_deinit();
 
@@ -170,7 +172,6 @@ int main(int argc, char *argv[])
        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;