diff options
author | David M. Lee <dlee@digium.com> | 2013-05-10 17:12:57 +0000 |
---|---|---|
committer | David M. Lee <dlee@digium.com> | 2013-05-10 17:12:57 +0000 |
commit | 4666079b05ea3b189e4fdccc665f7a61bf3e5535 (patch) | |
tree | 826e54b6a78671d7e911cbff4799b31b0aed9a30 /res/res_stasis_http.c | |
parent | db925c3f066fc73849af06bcfc966467af349891 (diff) |
Address unload order issues for res_stasis* modules
I've noticed when doing a graceful shutdown that the res_stasis_http.so
module gets unloaded before the modules that use it, which causes some
asserts during their unload.
While r386928 was a quick hack to get it to not assert and die, this
patch increases the use counts on res_stasis.so and res_stasis_http.so
properly. It's a bigger change than I expected, hence the review instead
of just committing it.
Review: https://reviewboard.asterisk.org/r/2489/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@388350 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_stasis_http.c')
-rw-r--r-- | res/res_stasis_http.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/res/res_stasis_http.c b/res/res_stasis_http.c index 92c9189a1..75a13284e 100644 --- a/res/res_stasis_http.c +++ b/res/res_stasis_http.c @@ -72,7 +72,6 @@ */ /*** MODULEINFO - <depend type="module">app_stasis</depend> <support_level>core</support_level> ***/ @@ -235,6 +234,7 @@ int stasis_http_add_handler(struct stasis_rest_handlers *handler) ao2_cleanup(root_handler); ao2_ref(new_handler, +1); root_handler = new_handler; + ast_module_ref(ast_module_info->self); return 0; } @@ -243,9 +243,7 @@ int stasis_http_remove_handler(struct stasis_rest_handlers *handler) RAII_VAR(struct stasis_rest_handlers *, new_handler, NULL, ao2_cleanup); size_t size, i, j; - if (!root_handler) { - return -1; - } + ast_assert(root_handler != NULL); ast_mutex_lock(&root_handler_lock); size = sizeof(*new_handler) + @@ -259,6 +257,7 @@ int stasis_http_remove_handler(struct stasis_rest_handlers *handler) for (i = 0, j = 0; i < root_handler->num_children; ++i) { if (root_handler->children[i] == handler) { + ast_module_unref(ast_module_info->self); continue; } new_handler->children[j++] = root_handler->children[i]; @@ -860,6 +859,7 @@ static struct ast_http_uri http_uri = { static int load_module(void) { ast_mutex_init(&root_handler_lock); + root_handler = root_handler_create(); if (!root_handler) { return AST_MODULE_LOAD_FAILURE; @@ -932,6 +932,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, .load = load_module, .unload = unload_module, .reload = reload_module, - .nonoptreq = "app_stasis", .load_pri = AST_MODPRI_APP_DEPEND, ); |