[asterisk-commits] mjordan: branch 13 r428789 - in /branches/13: ./ pbx/pbx_loopback.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Dec 2 11:06:07 CST 2014


Author: mjordan
Date: Tue Dec  2 11:05:59 2014
New Revision: 428789

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=428789
Log:
pbx/pbx_loopback: Speed up switches by avoiding unneeded lookups

This patch makes a small rearrangement to only do dialplan lookups during
loopback switches if the pattern matches. Prior to this patch, the dialplan
lookups were always performed, even when the result would be discarded.
Dialplan lookups can be very costly if remote switches - like DUNDi - are
present. In those cases extension matching is sped up considerably, making
the issue of lost digits more manageable.

As collateral damage, 6 trailing spaces were killed.

Review: https://reviewboard.asterisk.org/r/4211

ASTERISK-24577 #close
Reported by: Birger Harzenetter
patches:
  ast-loopback.patch uploaded by Birger Harzenetter (License 5870)
........

Merged revisions 428787 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 428788 from http://svn.asterisk.org/svn/asterisk/branches/12

Modified:
    branches/13/   (props changed)
    branches/13/pbx/pbx_loopback.c

Propchange: branches/13/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.

Modified: branches/13/pbx/pbx_loopback.c
URL: http://svnview.digium.com/svn/asterisk/branches/13/pbx/pbx_loopback.c?view=diff&rev=428789&r1=428788&r2=428789
==============================================================================
--- branches/13/pbx/pbx_loopback.c (original)
+++ branches/13/pbx/pbx_loopback.c Tue Dec  2 11:05:59 2014
@@ -53,16 +53,16 @@
    to modify the target extension, context, and priority in any way desired.
    If there is a match at the far end, execution jumps through the 'tunnel'
    to the matched context, extension, and priority.
- 
-   Global variables as well as ${CONTEXT}, ${EXTEN}, and ${PRIORITY} are 
+
+   Global variables as well as ${CONTEXT}, ${EXTEN}, and ${PRIORITY} are
    available for substitution.  After substitution Loopback expects to get
    a string of the form:
 
 	[exten]@context[:priority][/extramatch]
-   
+
    Where exten, context, and priority are another extension, context, and priority
    to lookup and "extramatch" is a dialplan extension pattern which the *original*
-   number must match.  If exten or priority are empty, the original values are 
+   number must match.  If exten or priority are empty, the original values are
    used.
 
    Note that the search context MUST be a different context from the current
@@ -80,7 +80,7 @@
 	char *newpattern=NULL; \
 	loopback_subst(buf, sizeof(buf), exten, context, priority, data); \
 	loopback_parse(&newexten, &newcontext, &newpriority, &newpattern, buf); \
-	ast_debug(1, "Parsed into %s @ %s priority %d\n", newexten, newcontext, newpriority); \
+	ast_debug(1, "Parsed into %s @ %s priority %d pattern %s\n", newexten, newcontext, newpriority, newpattern); \
 	if (!strcasecmp(newcontext, context)) return -1
 
 static char *loopback_subst(char *buf, int buflen, const char *exten, const char *context, int priority, const char *data)
@@ -132,18 +132,20 @@
 static int loopback_exists(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
 {
 	LOOPBACK_COMMON;
-	res = ast_exists_extension(chan, newcontext, newexten, newpriority, callerid);
 	if (newpattern && !ast_extension_match(newpattern, exten))
 		res = 0;
+	else
+		res = ast_exists_extension(chan, newcontext, newexten, newpriority, callerid);
 	return res;
 }
 
 static int loopback_canmatch(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
 {
 	LOOPBACK_COMMON;
-	res = ast_canmatch_extension(chan, newcontext, newexten, newpriority, callerid);
 	if (newpattern && !ast_extension_match(newpattern, exten))
 		res = 0;
+	else
+		res = ast_canmatch_extension(chan, newcontext, newexten, newpriority, callerid);
 	return res;
 }
 
@@ -158,9 +160,10 @@
 static int loopback_matchmore(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
 {
 	LOOPBACK_COMMON;
-	res = ast_matchmore_extension(chan, newcontext, newexten, newpriority, callerid);
 	if (newpattern && !ast_extension_match(newpattern, exten))
 		res = 0;
+	else
+		res = ast_matchmore_extension(chan, newcontext, newexten, newpriority, callerid);
 	return res;
 }
 




More information about the asterisk-commits mailing list