diff options
Diffstat (limited to 'main/sorcery.c')
-rw-r--r-- | main/sorcery.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/main/sorcery.c b/main/sorcery.c index cf4cd0213..4c60d1da1 100644 --- a/main/sorcery.c +++ b/main/sorcery.c @@ -253,6 +253,19 @@ static int sorcery_wizard_cmp(void *obj, void *arg, int flags) return !strcmp(wizard1->name, flags & OBJ_KEY ? name : wizard2->name) ? CMP_MATCH | CMP_STOP : 0; } +/*! \brief Cleanup function */ +static void sorcery_exit(void) +{ + ast_threadpool_shutdown(threadpool); + threadpool = NULL; +} + +/*! \brief Cleanup function for graceful shutdowns */ +static void sorcery_cleanup(void) +{ + ao2_cleanup(wizards); +} + int ast_sorcery_init(void) { struct ast_threadpool_options options = { @@ -265,6 +278,7 @@ int ast_sorcery_init(void) ast_assert(wizards == NULL); if (!(threadpool = ast_threadpool_create("Sorcery", NULL, &options))) { + threadpool = NULL; return -1; } @@ -273,6 +287,9 @@ int ast_sorcery_init(void) return -1; } + ast_register_cleanup(sorcery_cleanup); + ast_register_atexit(sorcery_exit); + return 0; } |