mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
Optimize how Stasis forwards are dispatched
This patch optimizes how forwards are dispatched in Stasis. Originally, forwards were dispatched as subscriptions that are invoked on the publishing thread. This did not account for the vast number of forwards we would end up having in the system, and the amount of work it would take to walk though the forward subscriptions. This patch modifies Stasis so that rather than walking the tree of forwards on every dispatch, when forwards and subscriptions are changed, the subscriber list for every topic in the tree is changed. This has a couple of benefits. First, this reduces the workload of dispatching messages. It also reduces contention when dispatching to different topics that happen to forward to the same aggregation topic (as happens with all of the channel, bridge and endpoint topics). Since forwards are no longer subscriptions, the bulk of this patch is simply changing stasis_subscription objects to stasis_forward objects (which, admittedly, I should have done in the first place.) Since this required me to yet again put in a growing array, I finally abstracted that out into a set of ast_vector macros in asterisk/vector.h. Review: https://reviewboard.asterisk.org/r/2883/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@400180 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -58,9 +58,9 @@ struct app_forwards {
|
||||
int interested;
|
||||
|
||||
/*! Forward for the regular topic */
|
||||
struct stasis_subscription *topic_forward;
|
||||
struct stasis_forward *topic_forward;
|
||||
/*! Forward for the caching topic */
|
||||
struct stasis_subscription *topic_cached_forward;
|
||||
struct stasis_forward *topic_cached_forward;
|
||||
|
||||
/*! Unique id of the object being forwarded */
|
||||
char id[];
|
||||
@@ -78,9 +78,9 @@ static void forwards_dtor(void *obj)
|
||||
|
||||
static void forwards_unsubscribe(struct app_forwards *forwards)
|
||||
{
|
||||
stasis_unsubscribe(forwards->topic_forward);
|
||||
stasis_forward_cancel(forwards->topic_forward);
|
||||
forwards->topic_forward = NULL;
|
||||
stasis_unsubscribe(forwards->topic_cached_forward);
|
||||
stasis_forward_cancel(forwards->topic_cached_forward);
|
||||
forwards->topic_cached_forward = NULL;
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ static struct app_forwards *forwards_create_channel(struct app *app,
|
||||
ast_channel_topic_cached(chan), app->topic);
|
||||
if (!forwards->topic_cached_forward) {
|
||||
/* Half-subscribed is a bad thing */
|
||||
stasis_unsubscribe(forwards->topic_forward);
|
||||
stasis_forward_cancel(forwards->topic_forward);
|
||||
forwards->topic_forward = NULL;
|
||||
return NULL;
|
||||
}
|
||||
@@ -163,7 +163,7 @@ static struct app_forwards *forwards_create_bridge(struct app *app,
|
||||
ast_bridge_topic_cached(bridge), app->topic);
|
||||
if (!forwards->topic_cached_forward) {
|
||||
/* Half-subscribed is a bad thing */
|
||||
stasis_unsubscribe(forwards->topic_forward);
|
||||
stasis_forward_cancel(forwards->topic_forward);
|
||||
forwards->topic_forward = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user