aboutsummaryrefslogtreecommitdiffstats
path: root/res
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2010-06-04 21:21:10 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2010-06-04 21:21:10 +0000
commit3ee45445dbb2b2acd64232ee93d3b64783eed7c8 (patch)
treeeb43cf0a58e1821505c73a092a76e1f91fc5411b /res
parent2c2c2d304ec1fcbc6804b86fb3ceeee19a5e5eca (diff)
Merged revisions 266735 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ........ r266735 | tilghman | 2010-06-01 13:02:24 -0500 (Tue, 01 Jun 2010) | 7 lines Don't register functions until the last possible point, so they're not unloaded unnecessarily. (closes issue #15996) Reported by: junky Patches: sdmi_wait.diff uploaded by junky (license 177) ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@268147 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res')
-rw-r--r--res/res_smdi.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/res/res_smdi.c b/res/res_smdi.c
index 84136dfe5..669b06521 100644
--- a/res/res_smdi.c
+++ b/res/res_smdi.c
@@ -1335,37 +1335,37 @@ static struct ast_custom_function smdi_msg_function = {
.read = smdi_msg_read,
};
-static int unload_module(void);
+static int _unload_module(int fromload);
static int load_module(void)
{
int res;
-
+
/* initialize our containers */
memset(&smdi_ifaces, 0, sizeof(smdi_ifaces));
ASTOBJ_CONTAINER_INIT(&smdi_ifaces);
-
+
ast_mutex_init(&mwi_monitor.lock);
ast_cond_init(&mwi_monitor.cond, NULL);
- ast_custom_function_register(&smdi_msg_retrieve_function);
- ast_custom_function_register(&smdi_msg_function);
-
/* load the config and start the listener threads*/
res = smdi_load(0);
if (res < 0) {
- unload_module();
+ _unload_module(1);
return res;
} else if (res == 1) {
- unload_module();
+ _unload_module(1);
ast_log(LOG_NOTICE, "No SMDI interfaces are available to listen on, not starting SMDI listener.\n");
return AST_MODULE_LOAD_DECLINE;
}
-
+
+ ast_custom_function_register(&smdi_msg_retrieve_function);
+ ast_custom_function_register(&smdi_msg_function);
+
return AST_MODULE_LOAD_SUCCESS;
}
-static int unload_module(void)
+static int _unload_module(int fromload)
{
/* this destructor stops any running smdi_read threads */
ASTOBJ_CONTAINER_DESTROYALL(&smdi_ifaces, ast_smdi_interface_destroy);
@@ -1382,12 +1382,19 @@ static int unload_module(void)
pthread_join(mwi_monitor.thread, NULL);
}
- ast_custom_function_unregister(&smdi_msg_retrieve_function);
- ast_custom_function_unregister(&smdi_msg_function);
+ if (!fromload) {
+ ast_custom_function_unregister(&smdi_msg_retrieve_function);
+ ast_custom_function_unregister(&smdi_msg_function);
+ }
return 0;
}
+static int unload_module(void)
+{
+ return _unload_module(0);
+}
+
static int reload(void)
{
int res;