Skip to content
Snippets Groups Projects
Commit 1403d1f1 authored by Joshua Colp's avatar Joshua Colp
Browse files

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
parent 175b9831
Branches
Tags
No related merge requests found
...@@ -39,25 +39,22 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") ...@@ -39,25 +39,22 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
static struct stasis_message_router *endpoint_router; 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) static void manager_endpoints_shutdown(void)
{ {
stasis_message_router_unsubscribe_and_join(endpoint_router); stasis_message_router_unsubscribe_and_join(endpoint_router);
endpoint_router = NULL; endpoint_router = NULL;
}
stasis_unsubscribe(topic_forwarder); static void endpoint_state_cb(void *data, struct stasis_subscription *sub,
topic_forwarder = NULL; 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) int manager_endpoints_init(void)
{ {
struct stasis_topic *manager_topic;
struct stasis_topic *endpoint_topic; struct stasis_topic *endpoint_topic;
struct stasis_message_router *message_router;
int ret = 0; int ret = 0;
if (endpoint_router) { if (endpoint_router) {
...@@ -67,30 +64,19 @@ int manager_endpoints_init(void) ...@@ -67,30 +64,19 @@ int manager_endpoints_init(void)
ast_register_atexit(manager_endpoints_shutdown); 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()); endpoint_topic = stasis_caching_get_topic(ast_endpoint_topic_all_cached());
if (!endpoint_topic) { if (!endpoint_topic) {
return -1; return -1;
} }
topic_forwarder = stasis_forward_all(endpoint_topic, manager_topic);
if (!topic_forwarder) {
return -1;
}
endpoint_router = stasis_message_router_create(endpoint_topic); endpoint_router = stasis_message_router_create(endpoint_topic);
if (!endpoint_router) { if (!endpoint_router) {
return -1; 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 /* If somehow we failed to add any routes, just shut down the whole
* thing and fail it. * thing and fail it.
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment