summaryrefslogtreecommitdiff
path: root/channels
diff options
context:
space:
mode:
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_alsa.c46
-rw-r--r--channels/chan_dahdi.c12
-rw-r--r--channels/chan_iax2.c33
-rw-r--r--channels/chan_mgcp.c10
-rw-r--r--channels/chan_motif.c2
-rw-r--r--channels/chan_nbs.c4
-rw-r--r--channels/chan_oss.c57
-rw-r--r--channels/chan_phone.c6
-rw-r--r--channels/chan_pjsip.c2
-rw-r--r--channels/chan_sip.c20
-rw-r--r--channels/chan_skinny.c6
-rw-r--r--channels/chan_unistim.c2
12 files changed, 109 insertions, 91 deletions
diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c
index c50b5408e..c53c1a344 100644
--- a/channels/chan_alsa.c
+++ b/channels/chan_alsa.c
@@ -924,6 +924,26 @@ static struct ast_cli_entry cli_alsa[] = {
AST_CLI_DEFINE(console_mute, "Disable/Enable mic input"),
};
+static int unload_module(void)
+{
+ ast_channel_unregister(&alsa_tech);
+ ast_cli_unregister_multiple(cli_alsa, ARRAY_LEN(cli_alsa));
+
+ if (alsa.icard)
+ snd_pcm_close(alsa.icard);
+ if (alsa.ocard)
+ snd_pcm_close(alsa.ocard);
+ if (alsa.owner)
+ ast_softhangup(alsa.owner, AST_SOFTHANGUP_APPUNLOAD);
+ if (alsa.owner)
+ return -1;
+
+ ao2_cleanup(alsa_tech.capabilities);
+ alsa_tech.capabilities = NULL;
+
+ return 0;
+}
+
/*!
* \brief Load the module
*
@@ -994,12 +1014,16 @@ static int load_module(void)
if (soundcard_init() < 0) {
ast_verb(2, "No sound card detected -- console channel will be unavailable\n");
ast_verb(2, "Turn off ALSA support by adding 'noload=chan_alsa.so' in /etc/asterisk/modules.conf\n");
+ unload_module();
+
return AST_MODULE_LOAD_DECLINE;
}
if (ast_channel_register(&alsa_tech)) {
ast_log(LOG_ERROR, "Unable to register channel class 'Console'\n");
- return AST_MODULE_LOAD_FAILURE;
+ unload_module();
+
+ return AST_MODULE_LOAD_DECLINE;
}
ast_cli_register_multiple(cli_alsa, ARRAY_LEN(cli_alsa));
@@ -1007,26 +1031,6 @@ static int load_module(void)
return AST_MODULE_LOAD_SUCCESS;
}
-static int unload_module(void)
-{
- ast_channel_unregister(&alsa_tech);
- ast_cli_unregister_multiple(cli_alsa, ARRAY_LEN(cli_alsa));
-
- if (alsa.icard)
- snd_pcm_close(alsa.icard);
- if (alsa.ocard)
- snd_pcm_close(alsa.ocard);
- if (alsa.owner)
- ast_softhangup(alsa.owner, AST_SOFTHANGUP_APPUNLOAD);
- if (alsa.owner)
- return -1;
-
- ao2_cleanup(alsa_tech.capabilities);
- alsa_tech.capabilities = NULL;
-
- return 0;
-}
-
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "ALSA Console Channel Driver",
.support_level = AST_MODULE_SUPPORT_EXTENDED,
.load = load_module,
diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c
index 97c80c83e..72fbe6e0c 100644
--- a/channels/chan_dahdi.c
+++ b/channels/chan_dahdi.c
@@ -19530,11 +19530,11 @@ static int load_module(void)
#endif /* defined(HAVE_PRI) || defined(HAVE_SS7) */
if (STASIS_MESSAGE_TYPE_INIT(dahdichannel_type)) {
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
if (!(dahdi_tech.capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
ast_format_cap_append(dahdi_tech.capabilities, ast_format_slin, 0);
ast_format_cap_append(dahdi_tech.capabilities, ast_format_ulaw, 0);
@@ -19542,7 +19542,7 @@ static int load_module(void)
if (dahdi_native_load(&dahdi_tech)) {
ao2_ref(dahdi_tech.capabilities, -1);
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
#ifdef HAVE_PRI
@@ -19560,7 +19560,7 @@ static int load_module(void)
if (ast_cc_agent_register(&dahdi_pri_cc_agent_callbacks)
|| ast_cc_monitor_register(&dahdi_pri_cc_monitor_callbacks)) {
__unload_module();
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
#endif /* defined(HAVE_PRI_CCSS) */
if (sig_pri_load(
@@ -19571,7 +19571,7 @@ static int load_module(void)
#endif /* defined(HAVE_PRI_CCSS) */
)) {
__unload_module();
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
#endif
#if defined(HAVE_SS7)
@@ -19594,7 +19594,7 @@ static int load_module(void)
if (ast_channel_register(&dahdi_tech)) {
ast_log(LOG_ERROR, "Unable to register channel class 'DAHDI'\n");
__unload_module();
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
#ifdef HAVE_PRI
ast_cli_register_multiple(dahdi_pri_cli, ARRAY_LEN(dahdi_pri_cli));
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 38dc5c00e..d15b55d72 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -14886,7 +14886,7 @@ container_fail:
if (calltoken_ignores) {
ao2_ref(calltoken_ignores, -1);
}
- return AST_MODULE_LOAD_FAILURE;
+ return -1;
}
@@ -15091,12 +15091,14 @@ static int load_module(void)
struct iax2_registry *reg = NULL;
if (!(iax2_tech.capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
ast_format_cap_append_by_type(iax2_tech.capabilities, AST_MEDIA_TYPE_UNKNOWN);
if (load_objects()) {
- return AST_MODULE_LOAD_FAILURE;
+ ao2_ref(iax2_tech.capabilities, -1);
+ iax2_tech.capabilities = NULL;
+ return AST_MODULE_LOAD_DECLINE;
}
memset(iaxs, 0, sizeof(iaxs));
@@ -15107,28 +15109,36 @@ static int load_module(void)
if (!(sched = ast_sched_context_create())) {
ast_log(LOG_ERROR, "Failed to create scheduler thread\n");
- return AST_MODULE_LOAD_FAILURE;
+ ao2_ref(iax2_tech.capabilities, -1);
+ iax2_tech.capabilities = NULL;
+ return AST_MODULE_LOAD_DECLINE;
}
if (ast_sched_start_thread(sched)) {
ast_sched_context_destroy(sched);
+ ao2_ref(iax2_tech.capabilities, -1);
+ iax2_tech.capabilities = NULL;
sched = NULL;
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
if (!(io = io_context_create())) {
ast_log(LOG_ERROR, "Failed to create I/O context\n");
ast_sched_context_destroy(sched);
+ ao2_ref(iax2_tech.capabilities, -1);
+ iax2_tech.capabilities = NULL;
sched = NULL;
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
if (!(netsock = ast_netsock_list_alloc())) {
ast_log(LOG_ERROR, "Failed to create netsock list\n");
io_context_destroy(io);
ast_sched_context_destroy(sched);
+ ao2_ref(iax2_tech.capabilities, -1);
+ iax2_tech.capabilities = NULL;
sched = NULL;
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
ast_netsock_init(netsock);
@@ -15137,8 +15147,10 @@ static int load_module(void)
ast_log(LOG_ERROR, "Could not allocate outsock list.\n");
io_context_destroy(io);
ast_sched_context_destroy(sched);
+ ao2_ref(iax2_tech.capabilities, -1);
+ iax2_tech.capabilities = NULL;
sched = NULL;
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
ast_netsock_init(outsock);
@@ -15157,6 +15169,7 @@ static int load_module(void)
ast_timer_close(timer);
timer = NULL;
}
+ __unload_module();
return AST_MODULE_LOAD_DECLINE;
}
@@ -15182,7 +15195,7 @@ static int load_module(void)
if (ast_channel_register(&iax2_tech)) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", "IAX2");
__unload_module();
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
if (ast_register_switch(&iax2_switch)) {
@@ -15192,7 +15205,7 @@ static int load_module(void)
if (start_network_thread()) {
ast_log(LOG_ERROR, "Unable to start network thread\n");
__unload_module();
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
} else {
ast_verb(2, "IAX Ready and Listening\n");
}
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index af79e218e..6cac4bc8a 100644
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -4860,11 +4860,11 @@ static int reload_config(int reload)
static int load_module(void)
{
if (!(global_capability = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
if (!(mgcp_tech.capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
ao2_ref(global_capability, -1);
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
ast_format_cap_append(global_capability, ast_format_ulaw, 0);
ast_format_cap_append(mgcp_tech.capabilities, ast_format_ulaw, 0);
@@ -4873,7 +4873,7 @@ static int load_module(void)
ast_log(LOG_WARNING, "Unable to create schedule context\n");
ao2_ref(global_capability, -1);
ao2_ref(mgcp_tech.capabilities, -1);
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
if (!(io = io_context_create())) {
@@ -4881,7 +4881,7 @@ static int load_module(void)
ast_sched_context_destroy(sched);
ao2_ref(global_capability, -1);
ao2_ref(mgcp_tech.capabilities, -1);
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
if (reload_config(0)) {
@@ -4897,7 +4897,7 @@ static int load_module(void)
ast_sched_context_destroy(sched);
ao2_ref(global_capability, -1);
ao2_ref(mgcp_tech.capabilities, -1);
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
ast_rtp_glue_register(&mgcp_rtp_glue);
diff --git a/channels/chan_motif.c b/channels/chan_motif.c
index 5828a1155..7d696e87d 100644
--- a/channels/chan_motif.c
+++ b/channels/chan_motif.c
@@ -2788,7 +2788,7 @@ end:
ao2_cleanup(jingle_tech.capabilities);
jingle_tech.capabilities = NULL;
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
/*! \brief Reload module */
diff --git a/channels/chan_nbs.c b/channels/chan_nbs.c
index 61e5398c3..a12470cee 100644
--- a/channels/chan_nbs.c
+++ b/channels/chan_nbs.c
@@ -257,12 +257,14 @@ static int unload_module(void)
static int load_module(void)
{
if (!(nbs_tech.capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
ast_format_cap_append(nbs_tech.capabilities, ast_format_slin, 0);
/* Make sure we can register our channel type */
if (ast_channel_register(&nbs_tech)) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
+ ao2_ref(nbs_tech.capabilities, -1);
+ nbs_tech.capabilities = NULL;
return AST_MODULE_LOAD_DECLINE;
}
return AST_MODULE_LOAD_SUCCESS;
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");
diff --git a/channels/chan_phone.c b/channels/chan_phone.c
index aa10a5620..76891ac98 100644
--- a/channels/chan_phone.c
+++ b/channels/chan_phone.c
@@ -1416,7 +1416,7 @@ static int load_module(void)
if (ast_mutex_lock(&iflock)) {
/* It's a little silly to lock it, but we mind as well just to be sure */
ast_log(LOG_ERROR, "Unable to lock interface list???\n");
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
v = ast_variable_browse(cfg, "interfaces");
while(v) {
@@ -1432,7 +1432,7 @@ static int load_module(void)
ast_config_destroy(cfg);
ast_mutex_unlock(&iflock);
__unload_module();
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
} else if (!strcasecmp(v->name, "silencesupression")) {
silencesupression = ast_true(v->value);
@@ -1508,7 +1508,7 @@ static int load_module(void)
ast_log(LOG_ERROR, "Unable to register channel class 'Phone'\n");
ast_config_destroy(cfg);
__unload_module();
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
ast_config_destroy(cfg);
/* And start the monitor for the first time */
diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index 46c74adf7..a92816431 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -2749,7 +2749,7 @@ end:
ast_channel_unregister(&chan_pjsip_tech);
ast_rtp_glue_unregister(&chan_pjsip_rtp_glue);
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
/*! \brief Unload the PJSIP channel from Asterisk */
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 792df5c38..6fd7e8634 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -35287,17 +35287,17 @@ static int load_module(void)
if (STASIS_MESSAGE_TYPE_INIT(session_timeout_type)) {
unload_module();
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
if (!(sip_tech.capabilities = ast_format_cap_alloc(0))) {
unload_module();
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
if (ast_sip_api_provider_register(&chan_sip_api_provider)) {
unload_module();
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
/* the fact that ao2_containers can't resize automatically is a major worry! */
@@ -35312,12 +35312,12 @@ static int load_module(void)
|| !threadt) {
ast_log(LOG_ERROR, "Unable to create primary SIP container(s)\n");
unload_module();
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
if (!(sip_cfg.caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
unload_module();
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
ast_format_cap_append_by_type(sip_tech.capabilities, AST_MEDIA_TYPE_AUDIO);
@@ -35328,13 +35328,13 @@ static int load_module(void)
if (!(sched = ast_sched_context_create())) {
ast_log(LOG_ERROR, "Unable to create scheduler context\n");
unload_module();
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
if (!(io = io_context_create())) {
ast_log(LOG_ERROR, "Unable to create I/O context\n");
unload_module();
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
sip_reloadreason = CHANNEL_MODULE_LOAD;
@@ -35349,7 +35349,7 @@ static int load_module(void)
if (!(bogus_peer = temp_peer("(bogus_peer)"))) {
ast_log(LOG_ERROR, "Unable to create bogus_peer for authentication\n");
unload_module();
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
/* Make sure the auth will always fail. */
ast_string_field_set(bogus_peer, md5secret, BOGUS_PEER_MD5SECRET);
@@ -35366,14 +35366,14 @@ static int load_module(void)
if (ast_msg_tech_register(&sip_msg_tech)) {
unload_module();
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
/* Make sure we can register our sip channel type */
if (ast_channel_register(&sip_tech)) {
ast_log(LOG_ERROR, "Unable to register channel type 'SIP'\n");
unload_module();
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
#ifdef TEST_FRAMEWORK
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index d1c2b927a..a0530007b 100644
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -8698,7 +8698,7 @@ static int load_module(void)
ao2_ref(skinny_tech.capabilities, -1);
ao2_ref(default_cap, -1);
ast_log(LOG_WARNING, "Unable to create schedule context\n");
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
/* Make sure we can register our skinny channel type */
@@ -8706,7 +8706,7 @@ static int load_module(void)
ao2_ref(default_cap, -1);
ao2_ref(skinny_tech.capabilities, -1);
ast_log(LOG_ERROR, "Unable to register channel class 'Skinny'\n");
- return -1;
+ return AST_MODULE_LOAD_DECLINE;
}
ast_rtp_glue_register(&skinny_rtp_glue);
@@ -8723,7 +8723,7 @@ static int load_module(void)
ast_channel_unregister(&skinny_tech);
ao2_ref(default_cap, -1);
ao2_ref(skinny_tech.capabilities, -1);
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
return AST_MODULE_LOAD_SUCCESS;
diff --git a/channels/chan_unistim.c b/channels/chan_unistim.c
index f82522111..b820cf51e 100644
--- a/channels/chan_unistim.c
+++ b/channels/chan_unistim.c
@@ -7126,7 +7126,7 @@ buff_failed:
global_cap = NULL;
ao2_cleanup(unistim_tech.capabilities);
unistim_tech.capabilities = NULL;
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
static int unload_module(void)