mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-19 11:42:27 +00:00
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
This commit is contained in:
@@ -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.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user