[asterisk-commits] mjordan: trunk r388976 - in /trunk: apps/ include/asterisk/ main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri May 17 12:44:01 CDT 2013
Author: mjordan
Date: Fri May 17 12:43:58 2013
New Revision: 388976
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=388976
Log:
Publish the outbound channel's application/data when dialing
This patch does two things:
* It fixes a bug where the outbound channel's application/data set by the
dialing API/app_dial is not communicated until the channel is hung up.
If that happens, AMI would incorrectly send a NewExten event immediately
after a Hangup. This isn't really AMI's fault, as the dialing APIs never
communicated the 'helpful' app/data on the outbound channel until it was
hungup.
* It makes public sending a stasis message about a change in channel state.
This is useful enough that - for now at least - it should be public. If
operations on a channel go to being more coarse-grained, this function
could be made private again.
Review: https://reviewboard.asterisk.org/r/2548
Note that this problem was found and reported by Matt DiMeo.
Modified:
trunk/apps/app_dial.c
trunk/include/asterisk/stasis_channels.h
trunk/main/channel.c
trunk/main/dial.c
trunk/main/stasis_channels.c
Modified: trunk/apps/app_dial.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_dial.c?view=diff&rev=388976&r1=388975&r2=388976
==============================================================================
--- trunk/apps/app_dial.c (original)
+++ trunk/apps/app_dial.c Fri May 17 12:43:58 2013
@@ -972,6 +972,7 @@
ast_channel_appl_set(c, "AppDial");
ast_channel_data_set(c, "(Outgoing Line)");
+ ast_publish_channel_state(c);
ast_channel_unlock(in);
if (single && !ast_test_flag64(o, OPT_IGNORE_CONNECTEDLINE)) {
@@ -2453,6 +2454,8 @@
ast_channel_appl_set(tc, "AppDial");
ast_channel_data_set(tc, "(Outgoing Line)");
+ ast_publish_channel_state(tc);
+
memset(ast_channel_whentohangup(tc), 0, sizeof(*ast_channel_whentohangup(tc)));
/* Determine CallerID to store in outgoing channel. */
Modified: trunk/include/asterisk/stasis_channels.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/stasis_channels.h?view=diff&rev=388976&r1=388975&r2=388976
==============================================================================
--- trunk/include/asterisk/stasis_channels.h (original)
+++ trunk/include/asterisk/stasis_channels.h Fri May 17 12:43:58 2013
@@ -297,6 +297,15 @@
const char *dialstring,
const char *dialstatus);
+/*!
+ * \since 12
+ * \brief Publish in the \ref ast_channel_topic a \ref ast_channel_snapshot
+ * message indicating a change in channel state
+ *
+ * \param chan The channel whose state has changed
+ */
+void ast_publish_channel_state(struct ast_channel *chan);
+
/*! @} */
/*!
Modified: trunk/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/channel.c?view=diff&rev=388976&r1=388975&r2=388976
==============================================================================
--- trunk/main/channel.c (original)
+++ trunk/main/channel.c Fri May 17 12:43:58 2013
@@ -814,26 +814,6 @@
return causes[x].cause;
return -1;
-}
-
-static void publish_channel_state(struct ast_channel *chan)
-{
- RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
- RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
-
- snapshot = ast_channel_snapshot_create(chan);
- if (!snapshot) {
- ast_log(LOG_ERROR, "Allocation error\n");
- return;
- }
-
- message = stasis_message_create(ast_channel_snapshot_type(), snapshot);
- if (!message) {
- return;
- }
-
- ast_assert(ast_channel_topic(chan) != NULL);
- stasis_publish(ast_channel_topic(chan), message);
}
static void publish_cache_clear(struct ast_channel *chan)
@@ -1176,7 +1156,7 @@
* a lot of data into this func to do it here!
*/
if (ast_get_channel_tech(tech) || (tech2 && ast_get_channel_tech(tech2))) {
- publish_channel_state(tmp);
+ ast_publish_channel_state(tmp);
}
ast_channel_internal_finalize(tmp);
@@ -2885,7 +2865,7 @@
ast_cc_offer(chan);
- publish_channel_state(chan);
+ ast_publish_channel_state(chan);
publish_cache_clear(chan);
if (ast_channel_cdr(chan) && !ast_test_flag(ast_channel_cdr(chan), AST_CDR_FLAG_BRIDGED) &&
@@ -7144,7 +7124,7 @@
ast_channel_redirecting_set(original, ast_channel_redirecting(clonechan));
ast_channel_redirecting_set(clonechan, &exchange.redirecting);
- publish_channel_state(original);
+ ast_publish_channel_state(original);
/* Restore original timing file descriptor */
ast_channel_set_fd(original, AST_TIMING_FD, ast_channel_timingfd(original));
@@ -7310,7 +7290,7 @@
ast_cdr_setcid(ast_channel_cdr(chan), chan);
}
- publish_channel_state(chan);
+ ast_publish_channel_state(chan);
ast_channel_unlock(chan);
}
@@ -7336,7 +7316,7 @@
ast_channel_lock(chan);
ast_party_caller_set(ast_channel_caller(chan), caller, update);
- publish_channel_state(chan);
+ ast_publish_channel_state(chan);
if (ast_channel_cdr(chan)) {
ast_cdr_setcid(ast_channel_cdr(chan), chan);
}
@@ -7363,7 +7343,7 @@
* we override what they are saying the state is and things go amuck. */
ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, (ast_test_flag(ast_channel_flags(chan), AST_FLAG_DISABLE_DEVSTATE_CACHE) ? AST_DEVSTATE_NOT_CACHABLE : AST_DEVSTATE_CACHABLE), name);
- publish_channel_state(chan);
+ ast_publish_channel_state(chan);
return 0;
}
Modified: trunk/main/dial.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/dial.c?view=diff&rev=388976&r1=388975&r2=388976
==============================================================================
--- trunk/main/dial.c (original)
+++ trunk/main/dial.c Fri May 17 12:43:58 2013
@@ -287,6 +287,7 @@
ast_channel_appl_set(channel->owner, "AppDial2");
ast_channel_data_set(channel->owner, "(Outgoing Line)");
+ ast_publish_channel_state(channel->owner);
memset(ast_channel_whentohangup(channel->owner), 0, sizeof(*ast_channel_whentohangup(channel->owner)));
/* Inherit everything from he who spawned this dial */
Modified: trunk/main/stasis_channels.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/stasis_channels.c?view=diff&rev=388976&r1=388975&r2=388976
==============================================================================
--- trunk/main/stasis_channels.c (original)
+++ trunk/main/stasis_channels.c Fri May 17 12:43:58 2013
@@ -415,6 +415,30 @@
}
publish_message_for_channel_topics(msg, chan);
+}
+
+void ast_publish_channel_state(struct ast_channel *chan)
+{
+ RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
+ RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
+
+ ast_assert(chan != NULL);
+ if (!chan) {
+ return;
+ }
+
+ snapshot = ast_channel_snapshot_create(chan);
+ if (!snapshot) {
+ return;
+ }
+
+ message = stasis_message_create(ast_channel_snapshot_type(), snapshot);
+ if (!message) {
+ return;
+ }
+
+ ast_assert(ast_channel_topic(chan) != NULL);
+ stasis_publish(ast_channel_topic(chan), message);
}
struct ast_json *ast_channel_snapshot_to_json(const struct ast_channel_snapshot *snapshot)
More information about the asterisk-commits
mailing list