[asterisk-commits] rmudgett: branch rmudgett/hangup_handlers r369181 - in /team/rmudgett/hangup_...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jun 21 15:07:16 CDT 2012


Author: rmudgett
Date: Thu Jun 21 15:07:14 2012
New Revision: 369181

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=369181
Log:
Commit current hangup handler work.

* Update app_queue and app_followme for hangup handlers.

* Fix app_queue F and F(x) option to check ast_pbx_start() return value.

* Tweak ast_autoservice_chan_hangup_peer() autoservice return code
handling.

* Fix CCSS generic_recall() to check ast_pbx_start() return value.

Needs more testing and bridge peer calling hangup handlers where needed.

Modified:
    team/rmudgett/hangup_handlers/apps/app_followme.c
    team/rmudgett/hangup_handlers/apps/app_queue.c
    team/rmudgett/hangup_handlers/main/autoservice.c
    team/rmudgett/hangup_handlers/main/ccss.c
    team/rmudgett/hangup_handlers/main/channel.c

Modified: team/rmudgett/hangup_handlers/apps/app_followme.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/hangup_handlers/apps/app_followme.c?view=diff&rev=369181&r1=369180&r2=369181
==============================================================================
--- team/rmudgett/hangup_handlers/apps/app_followme.c (original)
+++ team/rmudgett/hangup_handlers/apps/app_followme.c Thu Jun 21 15:07:14 2012
@@ -1490,7 +1490,7 @@
 		res = ast_channel_make_compatible(caller, outbound);
 		if (res < 0) {
 			ast_log(LOG_WARNING, "Had to drop call because I couldn't make %s compatible with %s\n", ast_channel_name(caller), ast_channel_name(outbound));
-			ast_hangup(outbound);
+			ast_autoservice_chan_hangup_peer(caller, outbound);
 			goto outrun;
 		}
 
@@ -1512,9 +1512,8 @@
 			}
 		}
 
-/* BUGBUG Update ast_bridge_call() here to see about calling ast_pbx_hangup_handler_run(). */
 		res = ast_bridge_call(caller, outbound, &config);
-		ast_hangup(outbound);
+		ast_autoservice_chan_hangup_peer(caller, outbound);
 	}
 
 outrun:

Modified: team/rmudgett/hangup_handlers/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/hangup_handlers/apps/app_queue.c?view=diff&rev=369181&r1=369180&r2=369181
==============================================================================
--- team/rmudgett/hangup_handlers/apps/app_queue.c (original)
+++ team/rmudgett/hangup_handlers/apps/app_queue.c Thu Jun 21 15:07:14 2012
@@ -5051,7 +5051,7 @@
 			if (!res2) {
 				if (qe->parent->memberdelay) {
 					ast_log(LOG_NOTICE, "Delaying member connect for %d seconds\n", qe->parent->memberdelay);
-					res2 |= ast_safe_sleep(peer, qe->parent->memberdelay * 1000);
+					res2 = ast_safe_sleep(peer, qe->parent->memberdelay * 1000);
 				}
 				if (!res2 && announce) {
 					if (play_file(peer, announce) < 0) {
@@ -5079,8 +5079,8 @@
 						}
 					}
 				}
-			}
-			res2 |= ast_autoservice_stop(qe->chan);
+				ast_autoservice_stop(qe->chan);
+			}
 			if (ast_check_hangup(peer)) {
 				/* Agent must have hung up */
 				ast_log(LOG_WARNING, "Agent on %s hungup on the customer.\n", ast_channel_name(peer));
@@ -5095,15 +5095,15 @@
 							"%s",
 							queuename, ast_channel_uniqueid(qe->chan), ast_channel_name(peer), member->interface, member->membername,
 							qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : "");
-				ast_hangup(peer);
+				ast_autoservice_chan_hangup_peer(qe->chan, peer);
 				ao2_ref(member, -1);
 				goto out;
-			} else if (res2) {
-				/* Caller must have hung up just before being connected*/
+			} else if (ast_check_hangup(qe->chan)) {
+				/* Caller must have hung up just before being connected */
 				ast_log(LOG_NOTICE, "Caller was about to talk to agent on %s but the caller hungup.\n", ast_channel_name(peer));
 				ast_queue_log(queuename, ast_channel_uniqueid(qe->chan), member->membername, "ABANDON", "%d|%d|%ld", qe->pos, qe->opos, (long) time(NULL) - qe->start);
 				record_abandoned(qe);
-				ast_hangup(peer);
+				ast_autoservice_chan_hangup_peer(qe->chan, peer);
 				ao2_ref(member, -1);
 				return -1;
 			}
@@ -5125,7 +5125,7 @@
 			ast_log(LOG_WARNING, "Had to drop call because I couldn't make %s compatible with %s\n", ast_channel_name(qe->chan), ast_channel_name(peer));
 			record_abandoned(qe);
 			ast_cdr_failed(ast_channel_cdr(qe->chan));
-			ast_hangup(peer);
+			ast_autoservice_chan_hangup_peer(qe->chan, peer);
 			ao2_ref(member, -1);
 			return -1;
 		}
@@ -5432,7 +5432,6 @@
 
 		time(&callstart);
 		transfer_ds = setup_transfer_datastore(qe, member, callstart, callcompletedinsl);
-/* BUGBUG Update ast_bridge_call() here to see about calling ast_pbx_hangup_handler_run(). */
 		bridge = ast_bridge_call(qe->chan,peer, &bridge_config);
 
 		/* If the queue member did an attended transfer, then the TRANSFER already was logged in the queue_log
@@ -5475,23 +5474,20 @@
 		}
 
 		if (!ast_check_hangup(peer) && ast_test_flag(&opts, OPT_CALLEE_GO_ON)) {
+			int goto_res;
+
 			if (!ast_strlen_zero(opt_args[OPT_ARG_CALLEE_GO_ON])) {
 				ast_replace_subargument_delimiter(opt_args[OPT_ARG_CALLEE_GO_ON]);
-
-				if (ast_parseable_goto(peer, opt_args[OPT_ARG_CALLEE_GO_ON]) == AST_PBX_SUCCESS) {
-					ast_pbx_start(peer);
-				} else {
-					ast_hangup(peer);
-				}
+				goto_res = ast_parseable_goto(peer, opt_args[OPT_ARG_CALLEE_GO_ON]);
 			} else { /* F() */
-				if (ast_goto_if_exists(peer, caller_context, caller_extension, caller_priority + 1) == AST_PBX_GOTO_FAILED) {
-					ast_hangup(peer);
-				} else {
-					ast_pbx_start(peer);
-				}
+				goto_res = ast_goto_if_exists(peer, caller_context, caller_extension,
+					caller_priority + 1);
+			}
+			if (goto_res || ast_pbx_start(peer)) {
+				ast_autoservice_chan_hangup_peer(qe->chan, peer);
 			}
 		} else {
-			ast_hangup(peer);
+			ast_autoservice_chan_hangup_peer(qe->chan, peer);
 		}
 
 		res = bridge ? bridge : 1;

Modified: team/rmudgett/hangup_handlers/main/autoservice.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/hangup_handlers/main/autoservice.c?view=diff&rev=369181&r1=369180&r2=369181
==============================================================================
--- team/rmudgett/hangup_handlers/main/autoservice.c (original)
+++ team/rmudgett/hangup_handlers/main/autoservice.c Thu Jun 21 15:07:14 2012
@@ -305,12 +305,11 @@
 
 void ast_autoservice_chan_hangup_peer(struct ast_channel *chan, struct ast_channel *peer)
 {
-	if (chan) {
-		ast_autoservice_start(chan);
-	}
-	ast_hangup(peer);
-	if (chan) {
+	if (chan && !ast_autoservice_start(chan)) {
+		ast_hangup(peer);
 		ast_autoservice_stop(chan);
+	} else {
+		ast_hangup(peer);
 	}
 }
 

Modified: team/rmudgett/hangup_handlers/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/hangup_handlers/main/ccss.c?view=diff&rev=369181&r1=369180&r2=369181
==============================================================================
--- team/rmudgett/hangup_handlers/main/ccss.c (original)
+++ team/rmudgett/hangup_handlers/main/ccss.c Thu Jun 21 15:07:14 2012
@@ -2744,8 +2744,13 @@
 			return NULL;
 		}
 	}
-	ast_cc_agent_recalling(agent->core_id, "Generic agent %s is recalling", agent->device_name);
-	ast_pbx_start(chan);
+	if (ast_pbx_start(chan)) {
+		ast_cc_failed(agent->core_id, "PBX failed to start for %s.", agent->device_name);
+		ast_hangup(chan);
+		return NULL;
+	}
+	ast_cc_agent_recalling(agent->core_id, "Generic agent %s is recalling",
+		agent->device_name);
 	return NULL;
 }
 

Modified: team/rmudgett/hangup_handlers/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/hangup_handlers/main/channel.c?view=diff&rev=369181&r1=369180&r2=369181
==============================================================================
--- team/rmudgett/hangup_handlers/main/channel.c (original)
+++ team/rmudgett/hangup_handlers/main/channel.c Thu Jun 21 15:07:14 2012
@@ -2649,6 +2649,16 @@
 	ast_set_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE);
 
 	ast_channel_unlock(chan);
+
+	/*
+	 * XXX if running the hangup handlers here causes problems
+	 * because the handlers take too long to execute, we could move
+	 * the meat of this function into another thread.  A thread
+	 * where channels go to die.
+	 *
+	 * If this is done, ast_autoservice_chan_hangup_peer() will no
+	 * longer be needed.
+	 */
 	ast_pbx_hangup_handler_run(chan);
 	ao2_unlink(channels, chan);
 	ast_channel_lock(chan);




More information about the asterisk-commits mailing list