mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-23 13:09:00 +00:00
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: https://origsvn.digium.com/svn/asterisk/trunk@266735 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -1389,37 +1389,37 @@ static struct ast_custom_function smdi_msg_function = {
|
|||||||
.read = smdi_msg_read,
|
.read = smdi_msg_read,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int unload_module(void);
|
static int _unload_module(int fromload);
|
||||||
|
|
||||||
static int load_module(void)
|
static int load_module(void)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
/* initialize our containers */
|
/* initialize our containers */
|
||||||
memset(&smdi_ifaces, 0, sizeof(smdi_ifaces));
|
memset(&smdi_ifaces, 0, sizeof(smdi_ifaces));
|
||||||
ASTOBJ_CONTAINER_INIT(&smdi_ifaces);
|
ASTOBJ_CONTAINER_INIT(&smdi_ifaces);
|
||||||
|
|
||||||
ast_mutex_init(&mwi_monitor.lock);
|
ast_mutex_init(&mwi_monitor.lock);
|
||||||
ast_cond_init(&mwi_monitor.cond, NULL);
|
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*/
|
/* load the config and start the listener threads*/
|
||||||
res = smdi_load(0);
|
res = smdi_load(0);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
unload_module();
|
_unload_module(1);
|
||||||
return res;
|
return res;
|
||||||
} else if (res == 1) {
|
} 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");
|
ast_log(LOG_NOTICE, "No SMDI interfaces are available to listen on, not starting SMDI listener.\n");
|
||||||
return AST_MODULE_LOAD_DECLINE;
|
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;
|
return AST_MODULE_LOAD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int unload_module(void)
|
static int _unload_module(int fromload)
|
||||||
{
|
{
|
||||||
/* this destructor stops any running smdi_read threads */
|
/* this destructor stops any running smdi_read threads */
|
||||||
ASTOBJ_CONTAINER_DESTROYALL(&smdi_ifaces, ast_smdi_interface_destroy);
|
ASTOBJ_CONTAINER_DESTROYALL(&smdi_ifaces, ast_smdi_interface_destroy);
|
||||||
@@ -1436,12 +1436,19 @@ static int unload_module(void)
|
|||||||
pthread_join(mwi_monitor.thread, NULL);
|
pthread_join(mwi_monitor.thread, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
ast_custom_function_unregister(&smdi_msg_retrieve_function);
|
if (!fromload) {
|
||||||
ast_custom_function_unregister(&smdi_msg_function);
|
ast_custom_function_unregister(&smdi_msg_retrieve_function);
|
||||||
|
ast_custom_function_unregister(&smdi_msg_function);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int unload_module(void)
|
||||||
|
{
|
||||||
|
return _unload_module(0);
|
||||||
|
}
|
||||||
|
|
||||||
static int reload(void)
|
static int reload(void)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
Reference in New Issue
Block a user