diff options
author | Joshua Colp <jcolp@digium.com> | 2013-06-23 00:02:01 +0000 |
---|---|---|
committer | Joshua Colp <jcolp@digium.com> | 2013-06-23 00:02:01 +0000 |
commit | 1403d1f17302e11e23e6ad835e5c57068aa46e7f (patch) | |
tree | 827ed622709edc5333997179c18c4c233e004bfc /main/manager_endpoints.c | |
parent | 175b9831f23ef97944398d476180682efa3b9a8b (diff) |
Fix a bug where messages were getting duplicated on AMI.
This was caused by forwarding all endpoint messages to manager which includes
channel messages that are related to the endpoint. This change causes only
the PeerStatus messages to be forwarded to manager thus eliminating the
duplicate channel messages.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@392627 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/manager_endpoints.c')
-rw-r--r-- | main/manager_endpoints.c | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/main/manager_endpoints.c b/main/manager_endpoints.c index 1a36424af..f0ed28a2c 100644 --- a/main/manager_endpoints.c +++ b/main/manager_endpoints.c @@ -39,25 +39,22 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") static struct stasis_message_router *endpoint_router; -/*! \brief The \ref stasis subscription returned by the forwarding of the endpoint topic - * to the manager topic - */ -static struct stasis_subscription *topic_forwarder; - static void manager_endpoints_shutdown(void) { stasis_message_router_unsubscribe_and_join(endpoint_router); endpoint_router = NULL; +} - stasis_unsubscribe(topic_forwarder); - topic_forwarder = NULL; +static void endpoint_state_cb(void *data, struct stasis_subscription *sub, + struct stasis_topic *topic, + struct stasis_message *message) +{ + stasis_forward_message(ast_manager_get_topic(), stasis_caching_get_topic(ast_endpoint_topic_all_cached()), message); } int manager_endpoints_init(void) { - struct stasis_topic *manager_topic; struct stasis_topic *endpoint_topic; - struct stasis_message_router *message_router; int ret = 0; if (endpoint_router) { @@ -67,30 +64,19 @@ int manager_endpoints_init(void) ast_register_atexit(manager_endpoints_shutdown); - manager_topic = ast_manager_get_topic(); - if (!manager_topic) { - return -1; - } - message_router = ast_manager_get_message_router(); - if (!message_router) { - return -1; - } endpoint_topic = stasis_caching_get_topic(ast_endpoint_topic_all_cached()); if (!endpoint_topic) { return -1; } - topic_forwarder = stasis_forward_all(endpoint_topic, manager_topic); - if (!topic_forwarder) { - return -1; - } - endpoint_router = stasis_message_router_create(endpoint_topic); if (!endpoint_router) { return -1; } + ret |= stasis_message_router_add(endpoint_router, ast_endpoint_state_type(), endpoint_state_cb, NULL); + /* If somehow we failed to add any routes, just shut down the whole * thing and fail it. */ |