mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-15 17:27:02 +00:00
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
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user