diff options
author | George Joseph <gjoseph@digium.com> | 2017-04-11 10:07:39 -0600 |
---|---|---|
committer | George Joseph <gjoseph@digium.com> | 2017-04-12 15:57:21 -0600 |
commit | 747beb1ed159f89a3b58742e4257740b3d6d6bba (patch) | |
tree | 3ba17dd62d0270a9ee976f173f948304b1733773 /res/res_chan_stats.c | |
parent | 60fd01f7f4b43515f5d4d915eec701c6054c53cf (diff) |
modules: change module LOAD_FAILUREs to LOAD_DECLINES
In all non-pbx modules, AST_MODULE_LOAD_FAILURE has been changed
to AST_MODULE_LOAD_DECLINE. This prevents asterisk from exiting
if a module can't be loaded. If the user wishes to retain the
FAILURE behavior for a specific module, they can use the "require"
or "preload-require" keyword in modules.conf.
A new API was added to logger: ast_is_logger_initialized(). This
allows asterisk.c/check_init() to print to the error log once the
logger subsystem is ready instead of just to stdout. If something
does fail before the logger is initialized, we now print to stderr
instead of stdout.
Change-Id: I5f4b50623d9b5a6cb7c5624a8c5c1274c13b2b25
Diffstat (limited to 'res/res_chan_stats.c')
-rw-r--r-- | res/res_chan_stats.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/res/res_chan_stats.c b/res/res_chan_stats.c index 9a26db78c..061d0867e 100644 --- a/res/res_chan_stats.c +++ b/res/res_chan_stats.c @@ -148,13 +148,22 @@ static void default_route(void *data, struct stasis_subscription *sub, } } +static int unload_module(void) +{ + stasis_unsubscribe_and_join(sub); + sub = NULL; + stasis_message_router_unsubscribe_and_join(router); + router = NULL; + return 0; +} + static int load_module(void) { /* You can create a message router to route messages by type */ router = stasis_message_router_create( ast_channel_topic_all_cached()); if (!router) { - return AST_MODULE_LOAD_FAILURE; + return AST_MODULE_LOAD_DECLINE; } stasis_message_router_add(router, stasis_cache_update_type(), updates, NULL); @@ -163,20 +172,12 @@ static int load_module(void) /* Or a subscription to receive all of the messages from a topic */ sub = stasis_subscribe(ast_channel_topic_all(), statsmaker, NULL); if (!sub) { - return AST_MODULE_LOAD_FAILURE; + unload_module(); + return AST_MODULE_LOAD_DECLINE; } return AST_MODULE_LOAD_SUCCESS; } -static int unload_module(void) -{ - stasis_unsubscribe_and_join(sub); - sub = NULL; - stasis_message_router_unsubscribe_and_join(router); - router = NULL; - return 0; -} - AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Example of how to use Stasis", .support_level = AST_MODULE_SUPPORT_EXTENDED, .load = load_module, |