[svn-commits] russell: branch 1.4 r90967 - /branches/1.4/main/pbx.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Dec 4 13:57:39 CST 2007


Author: russell
Date: Tue Dec  4 13:57:39 2007
New Revision: 90967

URL: http://svn.digium.com/view/asterisk?view=rev&rev=90967
Log:
Make some changes to some additions I made recently for doing channel autoservice
when looking up extensions.  This code was added to handle the case where a
dialplan switch was in use that could block for a long time.  However, the way
that I added it, it did this for all extension lookups.  However, lookups in the
in-memory tree of extensions should _not_ take long enough to matter.  So, move
the autoservice stuff to be only around executing a switch.

Modified:
    branches/1.4/main/pbx.c

Modified: branches/1.4/main/pbx.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/pbx.c?view=diff&rev=90967&r1=90966&r2=90967
==============================================================================
--- branches/1.4/main/pbx.c (original)
+++ branches/1.4/main/pbx.c Tue Dec  4 13:57:39 2007
@@ -1031,7 +1031,15 @@
 		else /* action == E_MATCH */
 			aswf = asw->exists;
 		datap = sw->eval ? sw->tmpdata : sw->data;
-		res = !aswf ? 0 : aswf(chan, context, exten, priority, callerid, datap);
+		if (!aswf)
+			res = 0;
+		else {
+			if (chan)
+				ast_autoservice_start(chan);
+			res = aswf(chan, context, exten, priority, callerid, datap);
+			if (chan)
+				ast_autoservice_stop(chan);
+		}
 		if (res) {	/* Got a match */
 			q->swo = asw;
 			q->data = datap;
@@ -1792,30 +1800,21 @@
 
 	int matching_action = (action == E_MATCH || action == E_CANMATCH || action == E_MATCHMORE);
 
-	if (c)
-		ast_autoservice_start(c);
-
 	ast_mutex_lock(&conlock);
 	e = pbx_find_extension(c, con, &q, context, exten, priority, label, callerid, action);
 	if (e) {
 		if (matching_action) {
 			ast_mutex_unlock(&conlock);
-			if (c)
-				ast_autoservice_stop(c);
 			return -1;	/* success, we found it */
 		} else if (action == E_FINDLABEL) { /* map the label to a priority */
 			res = e->priority;
 			ast_mutex_unlock(&conlock);
-			if (c)
-				ast_autoservice_stop(c);
 			return res;	/* the priority we were looking for */
 		} else {	/* spawn */
 			app = pbx_findapp(e->app);
 			ast_mutex_unlock(&conlock);
 			if (!app) {
 				ast_log(LOG_WARNING, "No application '%s' for extension (%s, %s, %d)\n", e->app, context, exten, priority);
-				if (c)
-					ast_autoservice_stop(c);
 				return -1;
 			}
 			if (c->context != context)
@@ -1845,23 +1844,17 @@
 					"AppData: %s\r\n"
 					"Uniqueid: %s\r\n",
 					c->name, c->context, c->exten, c->priority, app->name, passdata, c->uniqueid);
-			if (c)
-				ast_autoservice_stop(c);
 			return pbx_exec(c, app, passdata);	/* 0 on success, -1 on failure */
 		}
 	} else if (q.swo) {	/* not found here, but in another switch */
 		ast_mutex_unlock(&conlock);
 		if (matching_action) {
-			if (c)
-				ast_autoservice_stop(c);
 			return -1;
 		} else {
 			if (!q.swo->exec) {
 				ast_log(LOG_WARNING, "No execution engine for switch %s\n", q.swo->name);
 				res = -1;
 			}
-			if (c)
-				ast_autoservice_stop(c);
 			return q.swo->exec(c, q.foundcontext ? q.foundcontext : context, exten, priority, callerid, q.data);
 		}
 	} else {	/* not found anywhere, see what happened */
@@ -1887,9 +1880,6 @@
 			if (option_debug)
 				ast_log(LOG_DEBUG, "Shouldn't happen!\n");
 		}
-
-		if (c)
-			ast_autoservice_stop(c);
 
 		return (matching_action) ? 0 : -1;
 	}




More information about the svn-commits mailing list