[asterisk-commits] file: trunk r48699 - /trunk/main/pbx.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Wed Dec 20 20:20:09 MST 2006
Author: file
Date: Wed Dec 20 21:20:08 2006
New Revision: 48699
URL: http://svn.digium.com/view/asterisk?view=rev&rev=48699
Log:
Switch list of global variables to read/write locks.
Modified:
trunk/main/pbx.c
Modified: trunk/main/pbx.c
URL: http://svn.digium.com/view/asterisk/trunk/main/pbx.c?view=diff&rev=48699&r1=48698&r2=48699
==============================================================================
--- trunk/main/pbx.c (original)
+++ trunk/main/pbx.c Wed Dec 20 21:20:08 2006
@@ -240,7 +240,7 @@
int pbx_builtin_setvar(struct ast_channel *, void *);
static int pbx_builtin_importvar(struct ast_channel *, void *);
-AST_MUTEX_DEFINE_STATIC(globalslock);
+AST_RWLOCK_DEFINE_STATIC(globalslock);
static struct varshead globals = AST_LIST_HEAD_NOLOCK_INIT_VALUE;
static int autofallthrough = 1;
@@ -1190,7 +1190,7 @@
if (!places[i])
continue;
if (places[i] == &globals)
- ast_mutex_lock(&globalslock);
+ ast_rwlock_rdlock(&globalslock);
AST_LIST_TRAVERSE(places[i], variables, entries) {
if (strcasecmp(ast_var_name(variables), var)==0) {
s = ast_var_value(variables);
@@ -1198,7 +1198,7 @@
}
}
if (places[i] == &globals)
- ast_mutex_unlock(&globalslock);
+ ast_rwlock_unlock(&globalslock);
}
if (s == ¬_found || s == NULL)
*ret = NULL;
@@ -3643,12 +3643,12 @@
int i = 0;
struct ast_var_t *newvariable;
- ast_mutex_lock(&globalslock);
+ ast_rwlock_rdlock(&globalslock);
AST_LIST_TRAVERSE (&globals, newvariable, entries) {
i++;
ast_cli(fd, " %s=%s\n", ast_var_name(newvariable), ast_var_value(newvariable));
}
- ast_mutex_unlock(&globalslock);
+ ast_rwlock_unlock(&globalslock);
ast_cli(fd, "\n -- %d variables\n", i);
return RESULT_SUCCESS;
@@ -4661,12 +4661,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);
+ ast_rwlock_rdlock(&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);
+ ast_rwlock_unlock(&globalslock);
length = sizeof(struct ast_exten);
length += strlen(extension) + 1;
@@ -5688,7 +5688,7 @@
if (!places[i])
continue;
if (places[i] == &globals)
- ast_mutex_lock(&globalslock);
+ ast_rwlock_rdlock(&globalslock);
AST_LIST_TRAVERSE(places[i], variables, entries) {
if (!strcmp(name, ast_var_name(variables))) {
ret = ast_var_value(variables);
@@ -5696,7 +5696,7 @@
}
}
if (places[i] == &globals)
- ast_mutex_unlock(&globalslock);
+ ast_rwlock_unlock(&globalslock);
if (ret)
break;
}
@@ -5724,10 +5724,10 @@
ast_verbose(VERBOSE_PREFIX_2 "Setting global variable '%s' to '%s'\n", name, value);
newvariable = ast_var_assign(name, value);
if (headp == &globals)
- ast_mutex_lock(&globalslock);
+ ast_rwlock_wrlock(&globalslock);
AST_LIST_INSERT_HEAD(headp, newvariable, entries);
if (headp == &globals)
- ast_mutex_unlock(&globalslock);
+ ast_rwlock_unlock(&globalslock);
}
}
@@ -5755,7 +5755,7 @@
}
if (headp == &globals)
- ast_mutex_lock(&globalslock);
+ ast_rwlock_wrlock(&globalslock);
AST_LIST_TRAVERSE (headp, newvariable, entries) {
if (strcasecmp(ast_var_name(newvariable), nametail) == 0) {
/* there is already such a variable, delete it */
@@ -5773,7 +5773,7 @@
}
if (headp == &globals)
- ast_mutex_unlock(&globalslock);
+ ast_rwlock_unlock(&globalslock);
}
int pbx_builtin_setvar(struct ast_channel *chan, void *data)
@@ -5851,10 +5851,10 @@
{
struct ast_var_t *vardata;
- ast_mutex_lock(&globalslock);
+ ast_rwlock_wrlock(&globalslock);
while ((vardata = AST_LIST_REMOVE_HEAD(&globals, entries)))
ast_var_delete(vardata);
- ast_mutex_unlock(&globalslock);
+ ast_rwlock_unlock(&globalslock);
}
int pbx_checkcondition(const char *condition)
More information about the asterisk-commits
mailing list