summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2013-10-02 16:23:34 +0000
committerJoshua Colp <jcolp@digium.com>2013-10-02 16:23:34 +0000
commitc1235f2639023a9e450cafcdf8bd35cc304d9e53 (patch)
treeb48cb7bb27925ff48e4f807dda8ee9588fd36031 /main
parent424c0f2eb7ff45a06a21b2d81532ac49e24e8b60 (diff)
Reduce channel snapshot creation and publishing by up to 50%.
This change introduces the ability to stage channel snapshot creation and publishing by suppressing the implicit creation and publishing that some functions have. Once all operations are executed the staging is marked as done and a single snapshot is created and published. Review: https://reviewboard.asterisk.org/r/2889/ ........ Merged revisions 400265 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@400266 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r--main/bridge.c2
-rw-r--r--main/channel.c9
-rw-r--r--main/dial.c4
-rw-r--r--main/pbx.c4
-rw-r--r--main/stasis_channels.c15
5 files changed, 32 insertions, 2 deletions
diff --git a/main/bridge.c b/main/bridge.c
index 19350ed84..a972fe736 100644
--- a/main/bridge.c
+++ b/main/bridge.c
@@ -1151,8 +1151,10 @@ static void check_bridge_play_sounds(struct ast_bridge *bridge)
static void update_bridge_vars_set(struct ast_channel *chan, const char *name, const char *pvtid)
{
+ ast_channel_stage_snapshot(chan);
pbx_builtin_setvar_helper(chan, "BRIDGEPEER", name);
pbx_builtin_setvar_helper(chan, "BRIDGEPVTCALLID", pvtid);
+ ast_channel_stage_snapshot_done(chan);
}
/*!
diff --git a/main/channel.c b/main/channel.c
index e8ce5e0c5..36528f5df 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -876,6 +876,9 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
/* Channel structure allocation failure. */
return NULL;
}
+
+ ast_channel_stage_snapshot(tmp);
+
if (!(nativeformats = ast_format_cap_alloc())) {
ao2_ref(tmp, -1);
/* format capabilities structure allocation failure */
@@ -1020,7 +1023,7 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
* And now, since the channel structure is built, and has its name, let
* the world know of its existance
*/
- ast_channel_publish_snapshot(tmp);
+ ast_channel_stage_snapshot_done(tmp);
return tmp;
}
@@ -7716,8 +7719,12 @@ void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars)
{
struct ast_variable *cur;
+ ast_channel_stage_snapshot(chan);
+
for (cur = vars; cur; cur = cur->next)
pbx_builtin_setvar_helper(chan, cur->name, cur->value);
+
+ ast_channel_stage_snapshot_done(chan);
}
static void *silence_generator_alloc(struct ast_channel *chan, void *data)
diff --git a/main/dial.c b/main/dial.c
index 3b720fb9f..6d796e2b9 100644
--- a/main/dial.c
+++ b/main/dial.c
@@ -286,6 +286,8 @@ static int begin_dial_prerun(struct ast_dial_channel *channel, struct ast_channe
cap_request = NULL;
cap_all_audio = ast_format_cap_destroy(cap_all_audio);
+ ast_channel_stage_snapshot(channel->owner);
+
ast_channel_appl_set(channel->owner, "AppDial2");
ast_channel_data_set(channel->owner, "(Outgoing Line)");
ast_publish_channel_state(channel->owner);
@@ -312,6 +314,8 @@ static int begin_dial_prerun(struct ast_dial_channel *channel, struct ast_channe
ast_channel_transfercapability_set(channel->owner, ast_channel_transfercapability(chan));
}
+ ast_channel_stage_snapshot_done(channel->owner);
+
return 0;
}
diff --git a/main/pbx.c b/main/pbx.c
index 2a415401f..6b71c54b9 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -10050,7 +10050,9 @@ static int pbx_outgoing_attempt(const char *type, struct ast_format_cap *cap, co
return -1;
}
- ast_set_variables(dialed, vars);
+ if (vars) {
+ ast_set_variables(dialed, vars);
+ }
if (account) {
ast_channel_accountcode_set(dialed, account);
diff --git a/main/stasis_channels.c b/main/stasis_channels.c
index 0fbbf5d96..e1a3853e0 100644
--- a/main/stasis_channels.c
+++ b/main/stasis_channels.c
@@ -600,11 +600,26 @@ struct ast_json *ast_multi_channel_blob_get_json(struct ast_multi_channel_blob *
return obj->blob;
}
+void ast_channel_stage_snapshot(struct ast_channel *chan)
+{
+ ast_set_flag(ast_channel_flags(chan), AST_FLAG_SNAPSHOT_STAGE);
+}
+
+void ast_channel_stage_snapshot_done(struct ast_channel *chan)
+{
+ ast_clear_flag(ast_channel_flags(chan), AST_FLAG_SNAPSHOT_STAGE);
+ ast_channel_publish_snapshot(chan);
+}
+
void ast_channel_publish_snapshot(struct ast_channel *chan)
{
RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
+ if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_SNAPSHOT_STAGE)) {
+ return;
+ }
+
snapshot = ast_channel_snapshot_create(chan);
if (!snapshot) {
return;