[asterisk-commits] oej: branch oej/cancel_elsewhere_1.4 r171967 - in /team/oej/cancel_elsewhere_...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jan 28 11:44:57 CST 2009


Author: oej
Date: Wed Jan 28 11:44:57 2009
New Revision: 171967

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=171967
Log:
Make sure ANSWERED_ELSEWHERE works in combination with chan_local

In order for this to work, I had to check the calling channels flag and force
app_dial and app_queue to set it on the new (outbound) channel regardless
of the option to queue and dial. Now, queue members using local/123 at context
as members will not get missed calls if queue is called with the C option.


Modified:
    team/oej/cancel_elsewhere_1.4/apps/app_dial.c
    team/oej/cancel_elsewhere_1.4/apps/app_queue.c
    team/oej/cancel_elsewhere_1.4/channels/chan_local.c
    team/oej/cancel_elsewhere_1.4/main/channel.c

Modified: team/oej/cancel_elsewhere_1.4/apps/app_dial.c
URL: http://svn.digium.com/svn-view/asterisk/team/oej/cancel_elsewhere_1.4/apps/app_dial.c?view=diff&rev=171967&r1=171966&r2=171967
==============================================================================
--- team/oej/cancel_elsewhere_1.4/apps/app_dial.c (original)
+++ team/oej/cancel_elsewhere_1.4/apps/app_dial.c Wed Jan 28 11:44:57 2009
@@ -1350,6 +1350,9 @@
 			ast_app_group_set_channel(tmp->chan, outbound_group);
 		if (ast_test_flag(&opts, OPT_CANCEL_ELSEWHERE))
 			ast_set_flag(tmp->chan, AST_FLAG_ANSWERED_ELSEWHERE);
+		/* If the calling channel has the ANSWERED_ELSEWHERE flag set, inherit it. This is to support local channels */
+		if (ast_test_flag(chan, AST_FLAG_ANSWERED_ELSEWHERE))
+			ast_set_flag(tmp->chan, AST_FLAG_ANSWERED_ELSEWHERE);
 
 		/* Inherit context and extension */
 		if (!ast_strlen_zero(chan->macrocontext))

Modified: team/oej/cancel_elsewhere_1.4/apps/app_queue.c
URL: http://svn.digium.com/svn-view/asterisk/team/oej/cancel_elsewhere_1.4/apps/app_queue.c?view=diff&rev=171967&r1=171966&r2=171967
==============================================================================
--- team/oej/cancel_elsewhere_1.4/apps/app_queue.c (original)
+++ team/oej/cancel_elsewhere_1.4/apps/app_queue.c Wed Jan 28 11:44:57 2009
@@ -1707,8 +1707,11 @@
 		/* If someone else answered the call we should indicate this in the CANCEL */
 		/* Hangup any existing lines we have open */
 		if (outgoing->chan && (outgoing->chan != exception)) {
-			if (exception || cancel_answered_elsewhere)
+			if (exception || cancel_answered_elsewhere) {
 				ast_set_flag(outgoing->chan, AST_FLAG_ANSWERED_ELSEWHERE);
+				if (option_debug > 2)
+					ast_log(LOG_DEBUG, "Setting ANSWERED_ELSEWHERE FLAG ON THIS HANGUP -- %s\n", outgoing->chan->name);
+			}
 			ast_hangup(outgoing->chan);
 		}
 		oo = outgoing;
@@ -2795,6 +2798,13 @@
 			break;
 		}
 
+	/* if the calling channel has the ANSWERED_ELSEWHERE flag set, make sure this is inherited. 
+		(this is mainly to support chan_local)
+	*/
+	if (ast_test_flag(qe->chan, AST_FLAG_ANSWERED_ELSEWHERE)) {
+		cancel_answered_elsewhere = 1;
+	}
+
 	/* Hold the lock while we setup the outgoing calls */
 	if (use_weight)
 		AST_LIST_LOCK(&queues);

Modified: team/oej/cancel_elsewhere_1.4/channels/chan_local.c
URL: http://svn.digium.com/svn-view/asterisk/team/oej/cancel_elsewhere_1.4/channels/chan_local.c?view=diff&rev=171967&r1=171966&r2=171967
==============================================================================
--- team/oej/cancel_elsewhere_1.4/channels/chan_local.c (original)
+++ team/oej/cancel_elsewhere_1.4/channels/chan_local.c Wed Jan 28 11:44:57 2009
@@ -500,6 +500,11 @@
 		return -1;
 	}
 
+	/* Make sure we inherit the ANSWERED_ELSEWHERE flag if it's set on the queue/dial call request in the dialplan */
+	if (ast_test_flag(ast, AST_FLAG_ANSWERED_ELSEWHERE)) {
+		ast_set_flag(p->chan, AST_FLAG_ANSWERED_ELSEWHERE);
+	}
+
 	/* copy the channel variables from the incoming channel to the outgoing channel */
 	/* Note that due to certain assumptions, they MUST be in the same order */
 	AST_LIST_TRAVERSE(&p->owner->varshead, varptr, entries) {
@@ -539,9 +544,13 @@
 		ast_channel_lock(ast);
 	}
 
-	if (p->chan && ast_test_flag(ast, AST_FLAG_ANSWERED_ELSEWHERE)) 
+	isoutbound = IS_OUTBOUND(ast, p);
+
+	if (p->chan && ast_test_flag(ast, AST_FLAG_ANSWERED_ELSEWHERE)) {
 		ast_set_flag(p->chan, AST_FLAG_ANSWERED_ELSEWHERE);
-	isoutbound = IS_OUTBOUND(ast, p);
+		if (option_debug > 2)
+			ast_log(LOG_DEBUG, "This local call has the ANSWERED_ELSEWHERE flag set.\n");
+	}
 	if (isoutbound) {
 		const char *status = pbx_builtin_getvar_helper(p->chan, "DIALSTATUS");
 		if ((status) && (p->owner)) {

Modified: team/oej/cancel_elsewhere_1.4/main/channel.c
URL: http://svn.digium.com/svn-view/asterisk/team/oej/cancel_elsewhere_1.4/main/channel.c?view=diff&rev=171967&r1=171966&r2=171967
==============================================================================
--- team/oej/cancel_elsewhere_1.4/main/channel.c (original)
+++ team/oej/cancel_elsewhere_1.4/main/channel.c Wed Jan 28 11:44:57 2009
@@ -1514,6 +1514,10 @@
 					"is blocked by thread %ld in procedure %s!  Expect a failure\n",
 					(long)pthread_self(), chan->name, (long)chan->blocker, chan->blockproc);
 		ast_assert(ast_test_flag(chan, AST_FLAG_BLOCKING) == 0);
+	}
+
+	if (option_debug > 2 && ast_test_flag(chan, AST_FLAG_ANSWERED_ELSEWHERE)) {
+		ast_log(LOG_DEBUG, "This call is answered by someone else. ANSWERED_ELSEWHERE is set on '%s'\n", chan->name);
 	}
 	if (!ast_test_flag(chan, AST_FLAG_ZOMBIE)) {
 		if (option_debug)




More information about the asterisk-commits mailing list