summaryrefslogtreecommitdiff
path: root/pbx
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2007-02-28 20:46:01 +0000
committerJoshua Colp <jcolp@digium.com>2007-02-28 20:46:01 +0000
commite7b03a991ef101074af2b29fea568a3df7e9fa3b (patch)
tree93f9b6140eb5d6e502d59f61dc94af1c440c16b8 /pbx
parent00ab6324e87476bafb6a381093b48ffd8148825a (diff)
Convert the PBX core to use read/write locks. This yields a nifty performance improvement when it comes to simultaneous calls going through the dialplan. Using murf's test the old mutex based core took an average of 57.3 seconds while the rwlock based core took 31.1 seconds. That's a nifty 26.2 seconds performance improvement. The other good part is that if we do need to switch back then we just have to change the lock/unlock API calls. I converted everywhere that used to touch the mutex locks directly to use them.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@57184 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'pbx')
-rw-r--r--pbx/pbx_config.c38
-rw-r--r--pbx/pbx_dundi.c4
2 files changed, 21 insertions, 21 deletions
diff --git a/pbx/pbx_config.c b/pbx/pbx_config.c
index 217fb23ce..79a18da0b 100644
--- a/pbx/pbx_config.c
+++ b/pbx/pbx_config.c
@@ -138,7 +138,7 @@ static int lookup_ci(struct ast_context *c, const char *name)
{
struct ast_include *i = NULL;
- if (ast_lock_context(c)) /* error, skip */
+ if (ast_rdlock_context(c)) /* error, skip */
return 0;
while ( (i = ast_walk_context_includes(c, i)) )
if (!strcmp(name, ast_get_include_name(i)))
@@ -152,7 +152,7 @@ static int lookup_c_ip(struct ast_context *c, const char *name)
{
struct ast_ignorepat *ip = NULL;
- if (ast_lock_context(c)) /* error, skip */
+ if (ast_rdlock_context(c)) /* error, skip */
return 0;
while ( (ip = ast_walk_context_ignorepats(c, ip)) )
if (!strcmp(name, ast_get_ignorepat_name(ip)))
@@ -217,7 +217,7 @@ static char *complete_context_remove_include(const char *line, const char *word,
struct ast_context *c = NULL;
if (pos == 3) { /* "dialplan remove include _X_" */
- if (ast_lock_contexts()) {
+ if (ast_wrlock_contexts()) {
ast_log(LOG_ERROR, "Failed to lock context list\n");
return NULL;
}
@@ -225,7 +225,7 @@ static char *complete_context_remove_include(const char *line, const char *word,
while (!res && (c = ast_walk_contexts(c))) {
struct ast_include *i = NULL;
- if (ast_lock_context(c)) /* error ? skip this one */
+ if (ast_rdlock_context(c)) /* error ? skip this one */
continue;
while ( !res && (i = ast_walk_context_includes(c, i)) ) {
@@ -269,7 +269,7 @@ static char *complete_context_remove_include(const char *line, const char *word,
}
strsep(&dupline, " ");
- if (ast_lock_contexts()) {
+ if (ast_rdlock_contexts()) {
ast_log(LOG_ERROR, "Failed to lock contexts list\n");
free(context);
return NULL;
@@ -305,7 +305,7 @@ static char *complete_context_remove_include(const char *line, const char *word,
return NULL;
}
- if (ast_lock_contexts()) {
+ if (ast_rdlock_contexts()) {
ast_log(LOG_ERROR, "Failed to lock context list\n");
free(context);
return NULL;
@@ -480,7 +480,7 @@ static char *complete_context_remove_extension(const char *line, const char *wor
le = strlen(exten);
lc = strlen(context);
- if (ast_lock_contexts()) {
+ if (ast_rdlock_contexts()) {
ast_log(LOG_ERROR, "Failed to lock context list\n");
goto error2;
}
@@ -526,7 +526,7 @@ static char *complete_context_remove_extension(const char *line, const char *wor
if (le == 0 || lc == 0)
goto error3;
- if (ast_lock_contexts()) {
+ if (ast_rdlock_contexts()) {
ast_log(LOG_ERROR, "Failed to lock context list\n");
goto error3;
}
@@ -625,7 +625,7 @@ static char *complete_context_add_include(const char *line, const char *word, in
int len = strlen(word);
if (pos == 3) { /* 'dialplan add include _X_' (context) ... */
- if (ast_lock_contexts()) {
+ if (ast_rdlock_contexts()) {
ast_log(LOG_ERROR, "Failed to lock context list\n");
return NULL;
}
@@ -652,7 +652,7 @@ static char *complete_context_add_include(const char *line, const char *word, in
strsep(&dupline, " ");
/* check for context existence ... */
- if (ast_lock_contexts()) {
+ if (ast_rdlock_contexts()) {
ast_log(LOG_ERROR, "Failed to lock context list\n");
/* our fault, we can't check, so complete 'into' ... */
ret = strdup("into");
@@ -681,7 +681,7 @@ static char *complete_context_add_include(const char *line, const char *word, in
goto error3;
}
- if (ast_lock_contexts()) {
+ if (ast_rdlock_contexts()) {
ast_log(LOG_ERROR, "Failed to lock context list\n");
goto error3;
}
@@ -764,7 +764,7 @@ static int handle_save_dialplan(int fd, int argc, char *argv[])
cfg = ast_config_load("extensions.conf");
/* try to lock contexts list */
- if (ast_lock_contexts()) {
+ if (ast_rdlock_contexts()) {
ast_cli(fd, "Failed to lock contexts list\n");
ast_mutex_unlock(&save_dialplan_lock);
ast_config_destroy(cfg);
@@ -816,7 +816,7 @@ static int handle_save_dialplan(int fd, int argc, char *argv[])
struct ast_sw *sw;
/* try to lock context and fireout all info */
- if (ast_lock_context(c)) { /* lock failure */
+ if (ast_rdlock_context(c)) { /* lock failure */
incomplete = 1;
continue;
}
@@ -1042,7 +1042,7 @@ static char *complete_context_add_extension(const char *line, const char *word,
char *res = NULL;
/* try to lock contexts list ... */
- if (ast_lock_contexts()) {
+ if (ast_rdlock_contexts()) {
ast_log(LOG_WARNING, "Failed to lock contexts list\n");
return NULL;
}
@@ -1125,7 +1125,7 @@ static char *complete_context_add_ignorepat(const char *line, const char *word,
}
ignorepat = strsep(&dupline, " ");
- if (ast_lock_contexts()) {
+ if (ast_rdlock_contexts()) {
ast_log(LOG_ERROR, "Failed to lock contexts list\n");
return NULL;
}
@@ -1193,7 +1193,7 @@ static char *complete_context_remove_ignorepat(const char *line, const char *wor
if (pos == 3) {
int len = strlen(word);
- if (ast_lock_contexts()) {
+ if (ast_rdlock_contexts()) {
ast_log(LOG_WARNING, "Failed to lock contexts list\n");
return NULL;
}
@@ -1201,7 +1201,7 @@ static char *complete_context_remove_ignorepat(const char *line, const char *wor
for (c = NULL; !ret && (c = ast_walk_contexts(c));) {
struct ast_ignorepat *ip;
- if (ast_lock_context(c)) /* error, skip it */
+ if (ast_rdlock_context(c)) /* error, skip it */
continue;
for (ip = NULL; !ret && (ip = ast_walk_context_ignorepats(c, ip));) {
@@ -1243,14 +1243,14 @@ static char *complete_context_remove_ignorepat(const char *line, const char *wor
return NULL;
}
- if (ast_lock_contexts()) {
+ if (ast_rdlock_contexts()) {
ast_log(LOG_WARNING, "Failed to lock contexts list\n");
free(dupline);
return NULL;
}
for (c = NULL; !ret && (c = ast_walk_contexts(c)); ) {
- if (ast_lock_context(c)) /* fail, skip it */
+ if (ast_rdlock_context(c)) /* fail, skip it */
continue;
if (!partial_match(ast_get_context_name(c), word, len))
continue;
diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c
index cd7e96937..62c2c558b 100644
--- a/pbx/pbx_dundi.c
+++ b/pbx/pbx_dundi.c
@@ -3613,13 +3613,13 @@ static void dundi_precache_full(void)
AST_LIST_TRAVERSE(&mappings, cur, list) {
ast_log(LOG_NOTICE, "Should precache context '%s'\n", cur->dcontext);
- ast_lock_contexts();
+ ast_rdlock_contexts();
con = NULL;
while ((con = ast_walk_contexts(con))) {
if (strcasecmp(cur->lcontext, ast_get_context_name(con)))
continue;
/* Found the match, now queue them all up */
- ast_lock_context(con);
+ ast_rdlock_context(con);
e = NULL;
while ((e = ast_walk_context_extensions(con, e)))
reschedule_precache(ast_get_extension_name(e), cur->dcontext, 0);