[asterisk-commits] tilghman: branch 1.4 r107230 - /branches/1.4/main/pbx.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Mar 10 16:32:24 CDT 2008


Author: tilghman
Date: Mon Mar 10 16:32:24 2008
New Revision: 107230

URL: http://svn.digium.com/view/asterisk?view=rev&rev=107230
Log:
Use non-global storage for eswitch

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=107230&r1=107229&r2=107230
==============================================================================
--- branches/1.4/main/pbx.c (original)
+++ branches/1.4/main/pbx.c Mon Mar 10 16:32:24 2008
@@ -60,6 +60,7 @@
 #include "asterisk/app.h"
 #include "asterisk/devicestate.h"
 #include "asterisk/stringfields.h"
+#include "asterisk/threadstorage.h"
 
 /*!
  * \note I M P O R T A N T :
@@ -104,6 +105,8 @@
 });
 
 struct ast_context;
+
+AST_THREADSTORAGE(switch_data, switch_data_init);
 
 /*!
    \brief ast_exten: An extension
@@ -145,7 +148,6 @@
 	char *data;				/*!< Data load */
 	int eval;
 	AST_LIST_ENTRY(ast_sw) list;
-	char *tmpdata;
 	char stuff[0];
 };
 
@@ -946,6 +948,7 @@
 	struct ast_exten *e, *eroot;
 	struct ast_include *i;
 	struct ast_sw *sw;
+	char *tmpdata = NULL;
 
 	/* Initialize status if appropriate */
 	if (q->stacklen == 0) {
@@ -1024,8 +1027,13 @@
 			continue;
 		}
 		/* Substitute variables now */
-		if (sw->eval)
-			pbx_substitute_variables_helper(chan, sw->data, sw->tmpdata, SWITCH_DATA_LENGTH - 1);
+		if (sw->eval) {
+			if (!(tmpdata = ast_threadstorage_get(&switch_data, 512))) {
+				ast_log(LOG_WARNING, "Can't evaluate switch?!");
+				continue;
+			}
+			pbx_substitute_variables_helper(chan, sw->data, tmpdata, 512);
+		}
 
 		/* equivalent of extension_match_core() at the switch level */
 		if (action == E_CANMATCH)
@@ -1034,7 +1042,7 @@
 			aswf = asw->matchmore;
 		else /* action == E_MATCH */
 			aswf = asw->exists;
-		datap = sw->eval ? sw->tmpdata : sw->data;
+		datap = sw->eval ? tmpdata : sw->data;
 		if (!aswf)
 			res = 0;
 		else {
@@ -4389,11 +4397,6 @@
 	if (data)
 		length += strlen(data);
 	length++;
-	if (eval) {
-		/* Create buffer for evaluation of variables */
-		length += SWITCH_DATA_LENGTH;
-		length++;
-	}
 
 	/* allocate new sw structure ... */
 	if (!(new_sw = ast_calloc(1, length)))
@@ -4411,8 +4414,6 @@
 		strcpy(new_sw->data, "");
 		p++;
 	}
-	if (eval)
-		new_sw->tmpdata = p;
 	new_sw->eval	  = eval;
 	new_sw->registrar = registrar;
 




More information about the asterisk-commits mailing list