From a965613cf7eb65e9caf71d00614f00f9bda7c985 Mon Sep 17 00:00:00 2001 From: Matthew Jordan Date: Wed, 18 Jun 2014 04:22:05 +0000 Subject: [PATCH] stasis_channels: Update the stasis cache if manager variables are needed In r416211, the publishing of variable changes was modified such that a cached channel snapshot was used if manager variables were not requested with each AMI event. This was done to reduce the amount of channel snapshots created. However, an assumption was made that generating a channel snapshot and publishing the snapshot to the channel topic was sufficient to ensure that the cache would be updated; this is not the case. The channel snapshot type must be used to force a snapshot update. This patch updates the publication of channel variables such that the cache is updated prior to publication of the channel variable message if manager variables are in use. This ensures that all AMI events receive the variable update when they are supposed to. Note that this issue was caught by the Asterisk Test Suite (go go testing) ........ Merged revisions 416557 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@416561 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/stasis_channels.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/main/stasis_channels.c b/main/stasis_channels.c index ad9da50cfb..a1e7ad2094 100644 --- a/main/stasis_channels.c +++ b/main/stasis_channels.c @@ -707,14 +707,18 @@ void ast_channel_publish_varset(struct ast_channel *chan, const char *name, cons return; } - if (chan && !ast_channel_has_manager_vars()) { + /*! If there are manager variables, force a cache update */ + if (chan && ast_channel_has_manager_vars()) { + ast_channel_publish_snapshot(chan); + } + + if (chan) { ast_channel_publish_cached_blob(chan, ast_channel_varset_type(), blob); } else { - /* This function is NULL safe. If there are manager variables, - * we have to produce the full snapshot. - */ - ast_channel_publish_blob(chan, ast_channel_varset_type(), blob); + /* This function is NULL safe for global variables */ + ast_channel_publish_blob(NULL, ast_channel_varset_type(), blob); } + ast_json_unref(blob); } -- 2.47.2