aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-03-10 21:32:24 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-03-10 21:32:24 +0000
commita1677905551f6e77b223954b288050b966dd6692 (patch)
tree85f35ab31688af9cdaf5a89f06026e7bb8b36cc5 /main
parentad2dad921bbfcba24863f83a03d45b24d0b07a41 (diff)
Use non-global storage for eswitch
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@107230 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r--main/pbx.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/main/pbx.c b/main/pbx.c
index 669ca7d71..8d2aa108d 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -60,6 +60,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#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 :
@@ -105,6 +106,8 @@ AST_APP_OPTIONS(waitexten_opts, {
struct ast_context;
+AST_THREADSTORAGE(switch_data, switch_data_init);
+
/*!
\brief ast_exten: An extension
The dialplan is saved as a linked list with each context
@@ -145,7 +148,6 @@ struct ast_sw {
char *data; /*!< Data load */
int eval;
AST_LIST_ENTRY(ast_sw) list;
- char *tmpdata;
char stuff[0];
};
@@ -946,6 +948,7 @@ static struct ast_exten *pbx_find_extension(struct ast_channel *chan,
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 @@ static struct ast_exten *pbx_find_extension(struct ast_channel *chan,
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 @@ static struct ast_exten *pbx_find_extension(struct ast_channel *chan,
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 @@ int ast_context_add_switch2(struct ast_context *con, const char *value,
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 @@ int ast_context_add_switch2(struct ast_context *con, const char *value,
strcpy(new_sw->data, "");
p++;
}
- if (eval)
- new_sw->tmpdata = p;
new_sw->eval = eval;
new_sw->registrar = registrar;