From: Timo Sirainen Date: Wed, 22 Sep 2021 17:57:06 +0000 (+0300) Subject: dict: Wait for all dicts to finish pending operations at shutdown X-Git-Tag: 2.3.17~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=eb3da845e777b969d04608c22de40c00e0190821;p=thirdparty%2Fdovecot%2Fcore.git dict: Wait for all dicts to finish pending operations at shutdown This also changes the dict process to exit cleanly instead of early via lib_exit(). --- diff --git a/src/dict/dict-init-cache.c b/src/dict/dict-init-cache.c index 0e47e2ba16..ed76940b04 100644 --- a/src/dict/dict-init-cache.c +++ b/src/dict/dict-init-cache.c @@ -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); diff --git a/src/dict/dict-init-cache.h b/src/dict/dict-init-cache.h index e26944af9d..1342ca32e0 100644 --- a/src/dict/dict-init-cache.h +++ b/src/dict/dict-init-cache.h @@ -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 diff --git a/src/dict/main.c b/src/dict/main.c index 589efc6570..3d91854137 100644 --- a/src/dict/main.c +++ b/src/dict/main.c @@ -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;