Fix bridge/channel AMI event ordering issues

The stasis_cache_update messages are somewhat cumbersome to handle
with the stasis_message_router. Since all updates have the same
message type, they are normally handled with the same route.

Since caching itself is a first class component of stasis-core, it
makes sense for the router to handle the cache update messages itself.
This patch adds stasis_message_router_add_cache_update() and
stasis_message_router_remove_cache_update() to handle the routing of
stasis_cache_update messages.

This patch also corrects an issue with manager_{bridging,channels}.c,
where events might be reordered. The reordering occurs because the
components use different message routers, which they needed because
they both needed to route cache update messages. They now both use
manager's router, and add cache routes for just the cache updates they
are interested in.

(closes issue ASTERISK-22038)
Review: https://reviewboard.asterisk.org/r/2677/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@395118 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
David M. Lee
2013-07-23 13:39:50 +00:00
parent 5f56004b1d
commit fec667646f
6 changed files with 301 additions and 109 deletions

View File

@@ -726,9 +726,7 @@ static void channel_snapshot_update(void *data, struct stasis_subscription *sub,
update = stasis_message_data(message);
if (ast_channel_snapshot_type() != update->type) {
return;
}
ast_assert(ast_channel_snapshot_type() == update->type);
old_snapshot = stasis_message_data(update->old_snapshot);
new_snapshot = stasis_message_data(update->new_snapshot);
@@ -1283,85 +1281,57 @@ int manager_channels_init(void)
ast_register_atexit(manager_channels_shutdown);
ret |= stasis_message_router_add(message_router,
stasis_cache_update_type(),
channel_snapshot_update,
NULL);
ret |= stasis_message_router_add_cache_update(message_router,
ast_channel_snapshot_type(), channel_snapshot_update, NULL);
ret |= stasis_message_router_add(message_router,
ast_channel_user_event_type(),
channel_user_event_cb,
NULL);
ast_channel_user_event_type(), channel_user_event_cb, NULL);
ret |= stasis_message_router_add(message_router,
ast_channel_dtmf_begin_type(),
channel_dtmf_begin_cb,
NULL);
ast_channel_dtmf_begin_type(), channel_dtmf_begin_cb, NULL);
ret |= stasis_message_router_add(message_router,
ast_channel_dtmf_end_type(),
channel_dtmf_end_cb,
NULL);
ast_channel_dtmf_end_type(), channel_dtmf_end_cb, NULL);
ret |= stasis_message_router_add(message_router,
ast_channel_hangup_request_type(),
channel_hangup_request_cb,
NULL);
ast_channel_hangup_request_type(), channel_hangup_request_cb,
NULL);
ret |= stasis_message_router_add(message_router,
ast_channel_dial_type(),
channel_dial_cb,
NULL);
ast_channel_dial_type(), channel_dial_cb, NULL);
ret |= stasis_message_router_add(message_router,
ast_channel_hold_type(),
channel_hold_cb,
NULL);
ast_channel_hold_type(), channel_hold_cb, NULL);
ret |= stasis_message_router_add(message_router,
ast_channel_unhold_type(),
channel_unhold_cb,
NULL);
ast_channel_unhold_type(), channel_unhold_cb, NULL);
ret |= stasis_message_router_add(message_router,
ast_channel_fax_type(),
channel_fax_cb,
NULL);
ast_channel_fax_type(), channel_fax_cb, NULL);
ret |= stasis_message_router_add(message_router,
ast_channel_chanspy_start_type(),
channel_chanspy_start_cb,
NULL);
ast_channel_chanspy_start_type(), channel_chanspy_start_cb,
NULL);
ret |= stasis_message_router_add(message_router,
ast_channel_chanspy_stop_type(),
channel_chanspy_stop_cb,
NULL);
ast_channel_chanspy_stop_type(), channel_chanspy_stop_cb, NULL);
ret |= stasis_message_router_add(message_router,
ast_channel_hangup_handler_type(),
channel_hangup_handler_cb,
NULL);
ast_channel_hangup_handler_type(), channel_hangup_handler_cb,
NULL);
ret |= stasis_message_router_add(message_router,
ast_channel_moh_start_type(),
channel_moh_start_cb,
NULL);
ast_channel_moh_start_type(), channel_moh_start_cb, NULL);
ret |= stasis_message_router_add(message_router,
ast_channel_moh_stop_type(),
channel_moh_stop_cb,
NULL);
ast_channel_moh_stop_type(), channel_moh_stop_cb, NULL);
ret |= stasis_message_router_add(message_router,
ast_channel_monitor_start_type(),
channel_monitor_start_cb,
NULL);
ast_channel_monitor_start_type(), channel_monitor_start_cb,
NULL);
ret |= stasis_message_router_add(message_router,
ast_channel_monitor_stop_type(),
channel_monitor_stop_cb,
NULL);
ast_channel_monitor_stop_type(), channel_monitor_stop_cb, NULL);
/* If somehow we failed to add any routes, just shut down the whole
* thing and fail it.