[asterisk-commits] oej: branch group/whodidit-1.4 r364045 - in /team/group/whodidit-1.4: include...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Apr 26 14:10:24 CDT 2012


Author: oej
Date: Thu Apr 26 14:10:11 2012
New Revision: 364045

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=364045
Log:
Old code not committed

Modified:
    team/group/whodidit-1.4/include/asterisk/channel.h
    team/group/whodidit-1.4/main/channel.c

Modified: team/group/whodidit-1.4/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/group/whodidit-1.4/include/asterisk/channel.h?view=diff&rev=364045&r1=364044&r2=364045
==============================================================================
--- team/group/whodidit-1.4/include/asterisk/channel.h (original)
+++ team/group/whodidit-1.4/include/asterisk/channel.h Thu Apr 26 14:10:11 2012
@@ -539,6 +539,8 @@
 	 *  some non-traditional dialplans (like AGI) to continue to function.
 	 */
 	AST_FLAG_DISABLE_WORKAROUNDS = (1 << 20),
+	/*! Hangup channel already set, don't reset */
+	AST_FLAG_HANGUPCHANNEL_SET = (1 << 21),
 };
 
 /*! \brief ast_bridge_config flags */

Modified: team/group/whodidit-1.4/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/group/whodidit-1.4/main/channel.c?view=diff&rev=364045&r1=364044&r2=364045
==============================================================================
--- team/group/whodidit-1.4/main/channel.c (original)
+++ team/group/whodidit-1.4/main/channel.c Thu Apr 26 14:10:11 2012
@@ -1038,12 +1038,34 @@
 	return __ast_queue_frame(chan, fin, 1, NULL);
 }
 
+static void set_hangupchannelvars(struct ast_channel *chan, const char *name, int forget)
+{
+	if (!chan || ast_strlen_zero(name)) {
+		return;
+	}
+	if(ast_test_flag(chan, AST_FLAG_HANGUPCHANNEL_SET)) {
+		return;
+	}
+	if (!forget) {
+		ast_set_flag(chan, AST_FLAG_HANGUPCHANNEL_SET);
+	}
+
+	/* Set a channel variable */
+	pbx_builtin_setvar_helper(chan, "HANGUPCHANNEL", name);
+
+	/* Also set a cdr variable, that can be reached regardless of the cdr before h option */
+	if (chan->cdr) {
+		ast_cdr_setvar(chan->cdr, "hangupchannel", name, 0);
+	}
+}
+
 /*! \brief Queue a hangup frame for channel */
 int ast_queue_hangup(struct ast_channel *chan)
 {
 	struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP };
 	/* Yeah, let's not change a lock-critical value without locking */
 	if (!ast_channel_trylock(chan)) {
+		set_hangupchannelvars(chan, chan->name, 0);
 		chan->_softhangup |= AST_SOFTHANGUP_DEV;
 		ast_channel_unlock(chan);
 	}
@@ -1601,6 +1623,8 @@
 {
 	if (option_debug)
 		ast_log(LOG_DEBUG, "Soft-Hanging up channel '%s'\n", chan->name);
+
+	set_hangupchannelvars(chan, "system", 0);
 	/* Inform channel driver that we need to be hung up, if it cares */
 	chan->_softhangup |= cause;
 	ast_queue_frame(chan, &ast_null_frame);
@@ -4829,6 +4853,10 @@
 	ast_indicate(c0, AST_CONTROL_SRCUPDATE);
 	ast_indicate(c1, AST_CONTROL_SRCUPDATE);
 
+	/* Before we really know, blame the hangup on the peer */
+	set_hangupchannelvars(c0, c1->name, 1);
+	set_hangupchannelvars(c1, c0->name, 1);
+
 	for (/* ever */;;) {
 		struct timeval now = { 0, };
 		int to;




More information about the asterisk-commits mailing list