pbx_config.c: Don't crash when unloading module.
`pbx_config` subscribes to manager events to capture the `FullyBooted` event but fails to unsubscribe if the module is loaded after that event fires. If the module is unloaded, a crash occurs the next time a manager event is raised. We now unsubscribe when the module is unloaded if we haven't already unsubscribed. Fixes #470
This commit is contained in:
parent
1a0acabb8a
commit
1920639eab
|
@ -104,6 +104,8 @@ static int clearglobalvars_config = 0;
|
||||||
static int extenpatternmatchnew_config = 0;
|
static int extenpatternmatchnew_config = 0;
|
||||||
static char *overrideswitch_config = NULL;
|
static char *overrideswitch_config = NULL;
|
||||||
|
|
||||||
|
static struct stasis_subscription *fully_booted_subscription;
|
||||||
|
|
||||||
AST_MUTEX_DEFINE_STATIC(save_dialplan_lock);
|
AST_MUTEX_DEFINE_STATIC(save_dialplan_lock);
|
||||||
|
|
||||||
AST_MUTEX_DEFINE_STATIC(reload_lock);
|
AST_MUTEX_DEFINE_STATIC(reload_lock);
|
||||||
|
@ -1633,6 +1635,8 @@ static int unload_module(void)
|
||||||
ast_manager_unregister(AMI_EXTENSION_REMOVE);
|
ast_manager_unregister(AMI_EXTENSION_REMOVE);
|
||||||
ast_context_destroy(NULL, registrar);
|
ast_context_destroy(NULL, registrar);
|
||||||
|
|
||||||
|
stasis_unsubscribe_and_join(fully_booted_subscription);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1992,7 +1996,7 @@ static void startup_event_cb(void *data, struct stasis_subscription *sub, struct
|
||||||
|
|
||||||
ast_log(LOG_WARNING, "users.conf is deprecated and will be removed in a future version of Asterisk\n");
|
ast_log(LOG_WARNING, "users.conf is deprecated and will be removed in a future version of Asterisk\n");
|
||||||
|
|
||||||
stasis_unsubscribe(sub);
|
fully_booted_subscription = stasis_unsubscribe(fully_booted_subscription);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pbx_load_users(void)
|
static void pbx_load_users(void)
|
||||||
|
@ -2016,7 +2020,8 @@ static void pbx_load_users(void)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/*! \todo Remove users.conf support in Asterisk 23 */
|
/*! \todo Remove users.conf support in Asterisk 23 */
|
||||||
stasis_subscribe_pool(ast_manager_get_topic(), startup_event_cb, NULL);
|
fully_booted_subscription =
|
||||||
|
stasis_subscribe_pool(ast_manager_get_topic(), startup_event_cb, NULL);
|
||||||
|
|
||||||
for (cat = ast_category_browse(cfg, NULL); cat ; cat = ast_category_browse(cfg, cat)) {
|
for (cat = ast_category_browse(cfg, NULL); cat ; cat = ast_category_browse(cfg, cat)) {
|
||||||
if (!strcasecmp(cat, "general"))
|
if (!strcasecmp(cat, "general"))
|
||||||
|
|
Loading…
Reference in New Issue