diff options
author | zuul <zuul@gerrit.asterisk.org> | 2016-10-28 16:21:50 -0500 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2016-10-28 16:21:50 -0500 |
commit | 2995b31d189a12e19d5a9a1df07cf9ae8ac5b39a (patch) | |
tree | 1ca7dbdd975a7280d5f88b3e8a3a469fac848a12 | |
parent | badd38f03180c65cb5c4bdd6262cdee730a393dc (diff) | |
parent | d6ad86789702ab2e4161c5ea086cdae64c9b614d (diff) |
Merge "Fix shutdown crash caused by modules being left open."
-rw-r--r-- | include/asterisk/_private.h | 1 | ||||
-rw-r--r-- | include/asterisk/module.h | 7 | ||||
-rw-r--r-- | main/asterisk.c | 5 | ||||
-rw-r--r-- | main/loader.c | 5 |
4 files changed, 8 insertions, 10 deletions
diff --git a/include/asterisk/_private.h b/include/asterisk/_private.h index 36b316f2a..b3c2b2002 100644 --- a/include/asterisk/_private.h +++ b/include/asterisk/_private.h @@ -16,6 +16,7 @@ #define _ASTERISK__PRIVATE_H int load_modules(unsigned int); /*!< Provided by loader.c */ +int modules_shutdown(void); /*!< Provided by loader.c */ int load_pbx(void); /*!< Provided by pbx.c */ int load_pbx_builtins(void); /*!< Provided by pbx_builtins.c */ int load_pbx_functions_cli(void); /*!< Provided by pbx_functions.c */ diff --git a/include/asterisk/module.h b/include/asterisk/module.h index d5616e9d8..a80c7f843 100644 --- a/include/asterisk/module.h +++ b/include/asterisk/module.h @@ -228,13 +228,6 @@ int ast_loader_register(int (*updater)(void)); */ int ast_loader_unregister(int (*updater)(void)); -/*! - * \brief Run the unload() callback for all loaded modules - * - * This function should be called when Asterisk is shutting down gracefully. - */ -void ast_module_shutdown(void); - /*! * \brief Match modules names for the Asterisk cli. * \param line Unused by this function, but this should be the line we are diff --git a/main/asterisk.c b/main/asterisk.c index d4b39a265..56fc107db 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -2010,8 +2010,9 @@ static void really_quit(int num, shutdown_nice_t niceness, int restart) struct ast_json *json_object = NULL; int run_cleanups = niceness >= SHUTDOWN_NICE; - if (run_cleanups) { - ast_module_shutdown(); + if (run_cleanups && modules_shutdown()) { + ast_verb(0, "Some modules could not be unloaded, switching to fast shutdown\n"); + run_cleanups = 0; } if (!restart) { diff --git a/main/loader.c b/main/loader.c index 6617783cf..dacfce1f6 100644 --- a/main/loader.c +++ b/main/loader.c @@ -607,7 +607,7 @@ static struct ast_module *load_dynamic_module(const char *resource_in, unsigned #endif -void ast_module_shutdown(void) +int modules_shutdown(void) { struct ast_module *mod; int somethingchanged = 1, final = 0; @@ -655,7 +655,10 @@ void ast_module_shutdown(void) } } while (somethingchanged && !final); + final = AST_DLLIST_EMPTY(&module_list); AST_DLLIST_UNLOCK(&module_list); + + return !final; } int ast_unload_resource(const char *resource_name, enum ast_module_unload_mode force) |