diff options
author | David M. Lee <dlee@digium.com> | 2013-04-30 13:37:09 +0000 |
---|---|---|
committer | David M. Lee <dlee@digium.com> | 2013-04-30 13:37:09 +0000 |
commit | e2cd14876fcf0ca1af389112362ee120c60412b2 (patch) | |
tree | 1c62c655428f484bd056519ff7977a9b540d01ee /res | |
parent | 8dd9be0186b70a4345c308bc439dbe264b99f75c (diff) |
Just a couple of Stasis-HTTP nitpick fixes.
* Fixed crash when res_stasis_http is unloaded before the
implementation modules.
* Cleaned up test initialization for test_stasis_http.so.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@386928 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res')
-rw-r--r-- | res/res_stasis_http.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/res/res_stasis_http.c b/res/res_stasis_http.c index aa9c8a8cd..92c9189a1 100644 --- a/res/res_stasis_http.c +++ b/res/res_stasis_http.c @@ -241,14 +241,17 @@ int stasis_http_add_handler(struct stasis_rest_handlers *handler) int stasis_http_remove_handler(struct stasis_rest_handlers *handler) { RAII_VAR(struct stasis_rest_handlers *, new_handler, NULL, ao2_cleanup); - size_t old_size, new_size, i, j; + size_t size, i, j; - SCOPED_MUTEX(lock, &root_handler_lock); - old_size = sizeof(*new_handler) + + if (!root_handler) { + return -1; + } + + ast_mutex_lock(&root_handler_lock); + size = sizeof(*new_handler) + root_handler->num_children * sizeof(handler); - new_size = old_size - sizeof(handler); - new_handler = ao2_alloc(new_size, NULL); + new_handler = ao2_alloc(size, NULL); if (!new_handler) { return -1; } @@ -265,6 +268,7 @@ int stasis_http_remove_handler(struct stasis_rest_handlers *handler) ao2_cleanup(root_handler); ao2_ref(new_handler, +1); root_handler = new_handler; + ast_mutex_unlock(&root_handler_lock); return 0; } @@ -899,6 +903,7 @@ static int unload_module(void) ao2_global_obj_release(confs); ao2_cleanup(root_handler); + root_handler = NULL; ast_mutex_destroy(&root_handler_lock); return 0; |