[asterisk-commits] branch oej/managerstuff r12687 - in
/team/oej/managerstuff: ./ pbx.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Sun Mar 12 13:16:28 MST 2006
Author: oej
Date: Sun Mar 12 14:16:26 2006
New Revision: 12687
URL: http://svn.digium.com/view/asterisk?rev=12687&view=rev
Log:
reset automerge
Modified:
team/oej/managerstuff/ (props changed)
team/oej/managerstuff/pbx.c
Propchange: team/oej/managerstuff/
------------------------------------------------------------------------------
automerge = http://edvina.net/training/
Propchange: team/oej/managerstuff/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sun Mar 12 14:16:26 2006
@@ -1,1 +1,1 @@
-/branches/1.2:1-7496,7498-12627
+/branches/1.2:1-7496,7498-12686
Modified: team/oej/managerstuff/pbx.c
URL: http://svn.digium.com/view/asterisk/team/oej/managerstuff/pbx.c?rev=12687&r1=12686&r2=12687&view=diff
==============================================================================
--- team/oej/managerstuff/pbx.c (original)
+++ team/oej/managerstuff/pbx.c Sun Mar 12 14:16:26 2006
@@ -221,6 +221,7 @@
int pbx_builtin_setvar(struct ast_channel *, void *);
static int pbx_builtin_importvar(struct ast_channel *, void *);
+AST_MUTEX_DEFINE_STATIC(globalslock);
static struct varshead globals;
static int autofallthrough = 0;
@@ -1078,10 +1079,8 @@
}
if (!(*ret)) {
/* Try globals */
+ ast_mutex_lock(&globalslock);
AST_LIST_TRAVERSE(&globals,variables,entries) {
-#if 0
- ast_log(LOG_WARNING,"Comparing variable '%s' with '%s'\n",var,ast_var_name(variables));
-#endif
if (strcasecmp(ast_var_name(variables),var)==0) {
const char *s = ast_var_value(variables);
if (s) {
@@ -1090,6 +1089,7 @@
}
}
}
+ ast_mutex_unlock(&globalslock);
}
}
if (deprecated) {
@@ -4566,10 +4566,12 @@
/* if we are adding a hint, and there are global variables, and the hint
contains variable references, then expand them
*/
+ ast_mutex_lock(&globalslock);
if ((priority == PRIORITY_HINT) && AST_LIST_FIRST(&globals) && strstr(application, "${")) {
pbx_substitute_variables_varshead(&globals, application, expand_buf, sizeof(expand_buf));
application = expand_buf;
}
+ ast_mutex_unlock(&globalslock);
length = sizeof(struct ast_exten);
length += strlen(extension) + 1;
@@ -5934,24 +5936,34 @@
const char *pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
{
- struct ast_var_t *variables;
- int i;
- struct varshead *places[2] = { NULL, &globals };
-
- if (!name)
- return NULL;
- if (chan)
- places[0] = &chan->varshead;
-
- for (i = 0; i < 2; i++) {
- if (places[i]) {
- AST_LIST_TRAVERSE(places[i], variables, entries) {
- if (!strcmp(name, ast_var_name(variables)))
- return ast_var_value(variables);
- }
- }
- }
- return NULL;
+ struct ast_var_t *variables;
+ char *ret = NULL;
+ int i;
+ struct varshead *places[2] = { NULL, &globals };
+
+ if (!name)
+ return NULL;
+ if (chan)
+ places[0] = &chan->varshead;
+
+ for (i = 0; i < 2; i++) {
+ if (!places[i])
+ continue;
+ if (places[i] == &globals)
+ ast_mutex_lock(&globalslock);
+ AST_LIST_TRAVERSE(places[i], variables, entries) {
+ if (!strcmp(name, ast_var_name(variables))) {
+ ret = ast_var_value(variables);
+ break;
+ }
+ }
+ if (places[i] == &globals)
+ ast_mutex_unlock(&globalslock);
+ if (ret)
+ break;
+ }
+
+ return ret;
}
void pbx_builtin_pushvar_helper(struct ast_channel *chan, const char *name, const char *value)
@@ -5969,8 +5981,12 @@
if (value) {
if ((option_verbose > 1) && (headp == &globals))
ast_verbose(VERBOSE_PREFIX_2 "Setting global variable '%s' to '%s'\n", name, value);
- newvariable = ast_var_assign(name, value);
+ newvariable = ast_var_assign(name, value);
+ if (headp == &globals)
+ ast_mutex_lock(&globalslock);
AST_LIST_INSERT_HEAD(headp, newvariable, entries);
+ if (headp == &globals)
+ ast_mutex_unlock(&globalslock);
}
}
@@ -5992,6 +6008,8 @@
nametail++;
}
+ if (headp == &globals)
+ ast_mutex_lock(&globalslock);
AST_LIST_TRAVERSE (headp, newvariable, entries) {
if (strcasecmp(ast_var_name(newvariable), nametail) == 0) {
/* there is already such a variable, delete it */
@@ -5999,14 +6017,17 @@
ast_var_delete(newvariable);
break;
}
- }
-
+ }
+
if (value) {
if ((option_verbose > 1) && (headp == &globals))
ast_verbose(VERBOSE_PREFIX_2 "Setting global variable '%s' to '%s'\n", name, value);
newvariable = ast_var_assign(name, value);
AST_LIST_INSERT_HEAD(headp, newvariable, entries);
}
+
+ if (headp == &globals)
+ ast_mutex_unlock(&globalslock);
}
int pbx_builtin_setvar(struct ast_channel *chan, void *data)
@@ -6109,10 +6130,11 @@
void pbx_builtin_clear_globals(void)
{
struct ast_var_t *vardata;
- while (!AST_LIST_EMPTY(&globals)) {
- vardata = AST_LIST_REMOVE_HEAD(&globals, entries);
+
+ ast_mutex_lock(&globalslock);
+ while ((vardata = AST_LIST_REMOVE_HEAD(&globals, entries)))
ast_var_delete(vardata);
- }
+ ast_mutex_unlock(&globalslock);
}
static int pbx_checkcondition(char *condition)
More information about the asterisk-commits
mailing list