aboutsummaryrefslogtreecommitdiffstats
path: root/pbx/pbx_config.c
diff options
context:
space:
mode:
authorfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2007-02-28 20:46:01 +0000
committerfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2007-02-28 20:46:01 +0000
commit1b36eef6f45c9e4719848747494e1b839f5a1508 (patch)
tree93f9b6140eb5d6e502d59f61dc94af1c440c16b8 /pbx/pbx_config.c
parentb90c312913754e4e0f9dad38a9cc7b7ac21160d5 (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: http://svn.digium.com/svn/asterisk/trunk@57184 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'pbx/pbx_config.c')
-rw-r--r--pbx/pbx_config.c38
1 files changed, 19 insertions, 19 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;