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 /channels/chan_oss.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 'channels/chan_oss.c')
-rw-r--r-- | channels/chan_oss.c | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/channels/chan_oss.c b/channels/chan_oss.c index 3e1e38d37..ec112de38 100644 --- a/channels/chan_oss.c +++ b/channels/chan_oss.c @@ -1435,6 +1435,31 @@ error: #endif } +static int unload_module(void) +{ + struct chan_oss_pvt *o, *next; + + ast_channel_unregister(&oss_tech); + ast_cli_unregister_multiple(cli_oss, ARRAY_LEN(cli_oss)); + + o = oss_default.next; + while (o) { + close(o->sounddev); + if (o->owner) + ast_softhangup(o->owner, AST_SOFTHANGUP_APPUNLOAD); + if (o->owner) + return -1; + next = o->next; + ast_free(o->name); + ast_free(o); + o = next; + } + ao2_cleanup(oss_tech.capabilities); + oss_tech.capabilities = NULL; + + return 0; +} + /*! * \brief Load the module * @@ -1472,12 +1497,12 @@ static int load_module(void) if (find_desc(oss_active) == NULL) { ast_log(LOG_NOTICE, "Device %s not found\n", oss_active); /* XXX we could default to 'dsp' perhaps ? */ - /* XXX should cleanup allocated memory etc. */ - return AST_MODULE_LOAD_FAILURE; + unload_module(); + return AST_MODULE_LOAD_DECLINE; } if (!(oss_tech.capabilities = ast_format_cap_alloc(0))) { - return AST_MODULE_LOAD_FAILURE; + return AST_MODULE_LOAD_DECLINE; } ast_format_cap_append(oss_tech.capabilities, ast_format_slin, 0); @@ -1494,31 +1519,5 @@ static int load_module(void) return AST_MODULE_LOAD_SUCCESS; } - -static int unload_module(void) -{ - struct chan_oss_pvt *o, *next; - - ast_channel_unregister(&oss_tech); - ast_cli_unregister_multiple(cli_oss, ARRAY_LEN(cli_oss)); - - o = oss_default.next; - while (o) { - close(o->sounddev); - if (o->owner) - ast_softhangup(o->owner, AST_SOFTHANGUP_APPUNLOAD); - if (o->owner) - return -1; - next = o->next; - ast_free(o->name); - ast_free(o); - o = next; - } - ao2_cleanup(oss_tech.capabilities); - oss_tech.capabilities = NULL; - - return 0; -} - AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "OSS Console Channel Driver"); |