Stasis Core: Refactor ACL Change events to go out over the stasis core msg bus

(issue ASTERISK-21103)
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/2481/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@387037 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Jonathan Rose
2013-04-30 22:37:24 +00:00
parent 6f5733388a
commit 8e257fe819
9 changed files with 169 additions and 55 deletions

View File

@@ -844,7 +844,7 @@ static struct ast_flags global_flags[3] = {{0}}; /*!< global SIP_ flags */
static int global_t38_maxdatagram; /*!< global T.38 FaxMaxDatagram override */
static struct ast_event_sub *network_change_event_subscription; /*!< subscription id for network change events */
static struct ast_event_sub *acl_change_event_subscription; /*!< subscription id for named ACL system change events */
static struct stasis_subscription *acl_change_sub; /*!< subscription id for named ACL system change events */
static int network_change_event_sched_id = -1;
static char used_context[AST_MAX_CONTEXT]; /*!< name of automatically created context for unloading */
@@ -1285,7 +1285,7 @@ static void sip_poke_all_peers(void);
static void sip_peer_hold(struct sip_pvt *p, int hold);
static void mwi_event_cb(void *, struct stasis_subscription *, struct stasis_topic *, struct stasis_message *);
static void network_change_event_cb(const struct ast_event *, void *);
static void acl_change_event_cb(const struct ast_event *event, void *userdata);
static void acl_change_stasis_cb(void *data, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *message);
static void sip_keepalive_all_peers(void);
/*--- Applications, functions, CLI and manager command helpers */
@@ -16719,19 +16719,19 @@ static void network_change_event_unsubscribe(void)
}
}
static void acl_change_event_subscribe(void)
static void acl_change_stasis_subscribe(void)
{
if (!acl_change_event_subscription) {
acl_change_event_subscription = ast_event_subscribe(AST_EVENT_ACL_CHANGE,
acl_change_event_cb, "Manager must react to Named ACL changes", NULL, AST_EVENT_IE_END);
if (!acl_change_sub) {
acl_change_sub = stasis_subscribe(ast_acl_topic(),
acl_change_stasis_cb, NULL);
}
}
static void acl_change_event_unsubscribe(void)
{
if (acl_change_event_subscription) {
acl_change_event_subscription = ast_event_unsubscribe(acl_change_event_subscription);
if (acl_change_sub) {
acl_change_sub = stasis_unsubscribe(acl_change_sub);
}
}
@@ -29238,8 +29238,13 @@ static int restart_monitor(void)
return 0;
}
static void acl_change_event_cb(const struct ast_event *event, void *userdata)
static void acl_change_stasis_cb(void *data, struct stasis_subscription *sub,
struct stasis_topic *topic, struct stasis_message *message)
{
if (stasis_message_type(message) != ast_named_acl_change_type()) {
return;
}
ast_log(LOG_NOTICE, "Reloading chan_sip in response to ACL change event.\n");
ast_mutex_lock(&sip_reload_lock);
@@ -31383,7 +31388,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
/* If an ACL change subscription is needed and doesn't exist, we need one. */
if (acl_change_subscription_needed) {
acl_change_event_subscribe();
acl_change_stasis_subscribe();
}
return peer;
@@ -32621,7 +32626,7 @@ static int reload_config(enum channelreloadreason reason)
/* If an ACL change subscription is needed and doesn't exist, we need one. */
if (acl_change_subscription_needed) {
acl_change_event_subscribe();
acl_change_stasis_subscribe();
}
return 0;