[svn-commits] tilghman: trunk r164485 - in /trunk: ./ configs/ pbx/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Dec 15 15:17:07 CST 2008


Author: tilghman
Date: Mon Dec 15 15:17:07 2008
New Revision: 164485

URL: http://svn.digium.com/view/asterisk?view=rev&rev=164485
Log:
Allow disabling pattern match searches within the Realtime dialplan switch.
(closes issue #13698)
 Reported by: fhackenberger
 Patches: 
       20081211__bug13698.diff.txt uploaded by Corydon76 (license 14)
 Tested by: fhackenberger

Modified:
    trunk/CHANGES
    trunk/configs/extconfig.conf.sample
    trunk/pbx/pbx_realtime.c

Modified: trunk/CHANGES
URL: http://svn.digium.com/view/asterisk/trunk/CHANGES?view=diff&rev=164485&r1=164484&r2=164485
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Mon Dec 15 15:17:07 2008
@@ -87,6 +87,8 @@
    which are interpreted as relative to the astvarlibdir setting in asterisk.conf.
  * All deprecated CLI commands are removed from the sourcecode. They are now handled
    by the new clialiases module. See cli_aliases.conf.sample file.
+ * The realtime switch now supports an option flag, 'p', which disables searches for
+   pattern matches.
 
 Asterisk Manager Interface
 --------------------------

Modified: trunk/configs/extconfig.conf.sample
URL: http://svn.digium.com/view/asterisk/trunk/configs/extconfig.conf.sample?view=diff&rev=164485&r1=164484&r2=164485
==============================================================================
--- trunk/configs/extconfig.conf.sample (original)
+++ trunk/configs/extconfig.conf.sample Mon Dec 15 15:17:07 2008
@@ -60,4 +60,17 @@
 ;queue_members => odbc,asterisk
 ;musiconhold => mysql,asterisk
 ;queue_log => mysql,aasterisk
+;
+;
+; While most dynamic realtime engines are automatically used when defined in
+; this file, 'extensions', distinctively, is not.  To activate dynamic realtime
+; extensions, you must turn them on in each respective context within
+; extensions.conf with a switch statement.  The syntax is:
+;      switch => Realtime/[[db_context@]tablename]/<opts>
+; The only option available currently is the 'p' option, which disallows
+; extension pattern queries to the database.  If you have no patterns defined
+; in a particular context, this will save quite a bit of CPU time.  However,
+; note that using dynamic realtime extensions is not recommended anymore as a
+; best practice; instead, you should consider writing a static dialplan with
+; proper data abstraction via a tool like func_odbc.
 

Modified: trunk/pbx/pbx_realtime.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx/pbx_realtime.c?view=diff&rev=164485&r1=164484&r2=164485
==============================================================================
--- trunk/pbx/pbx_realtime.c (original)
+++ trunk/pbx/pbx_realtime.c Mon Dec 15 15:17:07 2008
@@ -46,6 +46,7 @@
 #include "asterisk/utils.h"
 #include "asterisk/crypto.h"
 #include "asterisk/astdb.h"
+#include "asterisk/app.h"
 
 #define MODE_MATCH 		0
 #define MODE_MATCHMORE 	1
@@ -53,6 +54,14 @@
 
 #define EXT_DATA_SIZE 256
 
+enum {
+	OPTION_PATTERNS_DISABLED = (1 << 0),
+} option_flags;
+
+AST_APP_OPTIONS(switch_opts, {
+	AST_APP_OPTION('p', OPTION_PATTERNS_DISABLED),
+});
+
 /* Realtime switch looks up extensions in the supplied realtime table.
 
 	[context@][realtimetable][/options]
@@ -67,7 +76,7 @@
 */
 
 
-static struct ast_variable *realtime_switch_common(const char *table, const char *context, const char *exten, int priority, int mode)
+static struct ast_variable *realtime_switch_common(const char *table, const char *context, const char *exten, int priority, int mode, struct ast_flags flags)
 {
 	struct ast_variable *var;
 	struct ast_config *cfg;
@@ -97,7 +106,7 @@
 		ast_copy_string(rexten, exten, sizeof(rexten));
 	}
 	var = ast_load_realtime(table, ematch, rexten, "context", context, "priority", pri, SENTINEL);
-	if (!var) {
+	if (!var && !ast_test_flag(&flags, OPTION_PATTERNS_DISABLED)) {
 		cfg = ast_load_realtime_multientry(table, "exten LIKE", "\\_%", "context", context, "priority", pri, SENTINEL);	
 		if (cfg) {
 			char *cat = ast_category_browse(cfg, NULL);
@@ -131,8 +140,11 @@
 	const char *ctx = NULL;
 	char *table;
 	struct ast_variable *var=NULL;
+	struct ast_flags flags = { 0, };
 	char *buf = ast_strdupa(data);
 	if (buf) {
+		/* "Realtime" prefix is stripped off in the parent engine.  The
+		 * remaining string is: [[context@]table][/opts] */
 		char *opts = strchr(buf, '/');
 		if (opts)
 			*opts++ = '\0';
@@ -143,7 +155,10 @@
 		}
 		ctx = S_OR(ctx, context);
 		table = S_OR(table, "extensions");
-		var = realtime_switch_common(table, ctx, exten, priority, mode);
+		if (!ast_strlen_zero(opts)) {
+			ast_app_parse_options(switch_opts, &flags, NULL, opts);
+		}
+		var = realtime_switch_common(table, ctx, exten, priority, mode, flags);
 	}
 	return var;
 }




More information about the svn-commits mailing list