mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
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
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user