[asterisk-commits] rmudgett: branch 1.8 r318282 - /branches/1.8/main/features.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon May 9 14:07:07 CDT 2011


Author: rmudgett
Date: Mon May  9 14:07:01 2011
New Revision: 318282

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=318282
Log:
Hangup extension executed twice.

When a user hangs up a call, in certain circumstances, the hangup
extension can end up being executed twice:

1) If a call is bridged and the 'h' extension executes the Hangup
application, then the 'h' extension will be executed twice.

2) If a call is bridged within a macro (Dial or Queue), it has its own 'h'
extension, the main context also has an 'h' extension, and the macro 'h'
extension executes the Hangup application, then both 'h' extensions will
be executed.

* Revert originally commited fix for #16106 and just set
AST_FLAG_BRIDGE_HANGUP_RUN unconditionally in ast_bridge_call().  The
bridge code just executed an 'h' extension so the main PBX loop does not
need to execute one as well.

(issue #16106)
Reported by: ajohnson

(issue #16548)
Reported by: hajekd

Modified:
    branches/1.8/main/features.c

Modified: branches/1.8/main/features.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/features.c?view=diff&rev=318282&r1=318281&r2=318282
==============================================================================
--- branches/1.8/main/features.c (original)
+++ branches/1.8/main/features.c Mon May  9 14:07:01 2011
@@ -3859,6 +3859,7 @@
 		if (bridge_cdr && ast_opt_end_cdr_before_h_exten) {
 			ast_cdr_end(bridge_cdr);
 		}
+
 		/* swap the bridge cdr and the chan cdr for a moment, and let the endbridge
 		   dialplan code operate on it */
 		ast_channel_lock(chan);
@@ -3873,24 +3874,19 @@
 		ast_copy_string(chan->exten, "h", sizeof(chan->exten));
 		chan->priority = 1;
 		ast_channel_unlock(chan);
+
 		while ((spawn_error = ast_spawn_extension(chan, chan->context, chan->exten,
 			chan->priority,
 			S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL),
 			&found, 1)) == 0) {
 			chan->priority++;
 		}
-		if (spawn_error
-			&& (!ast_exists_extension(chan, chan->context, chan->exten, chan->priority,
-				S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))
-				|| ast_check_hangup(chan))) {
-			/* if the extension doesn't exist or a hangup occurred, this isn't really a spawn error */
-			spawn_error = 0;
-		}
 		if (found && spawn_error) {
 			/* Something bad happened, or a hangup has been requested. */
 			ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", chan->context, chan->exten, chan->priority, chan->name);
 			ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", chan->context, chan->exten, chan->priority, chan->name);
 		}
+
 		/* swap it back */
 		ast_channel_lock(chan);
 		ast_copy_string(chan->exten, save_exten, sizeof(chan->exten));
@@ -3902,10 +3898,10 @@
 				bridge_cdr = NULL;
 			}
 		}
-		if (!spawn_error) {
-			ast_set_flag(chan, AST_FLAG_BRIDGE_HANGUP_RUN);
-		}
+		/* An "h" exten has been run, so indicate that one has been run. */
+		ast_set_flag(chan, AST_FLAG_BRIDGE_HANGUP_RUN);
 		ast_channel_unlock(chan);
+
 		/* protect the lastapp/lastdata against the effects of the hangup/dialplan code */
 		if (bridge_cdr) {
 			ast_copy_string(bridge_cdr->lastapp, savelastapp, sizeof(bridge_cdr->lastapp));




More information about the asterisk-commits mailing list