[asterisk-commits] qwell: branch 1.4 r49024 -
/branches/1.4/main/http.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Thu Dec 28 12:52:47 MST 2006
Author: qwell
Date: Thu Dec 28 13:52:46 2006
New Revision: 49024
URL: http://svn.digium.com/view/asterisk?view=rev&rev=49024
Log:
make the uris_lock a rwlock instead of a mutex lock - needs to be forward ported to trunk
Modified:
branches/1.4/main/http.c
Modified: branches/1.4/main/http.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/http.c?view=diff&rev=49024&r1=49023&r2=49024
==============================================================================
--- branches/1.4/main/http.c (original)
+++ branches/1.4/main/http.c Thu Dec 28 13:52:46 2006
@@ -64,7 +64,7 @@
ast_http_callback callback;
};
-AST_MUTEX_DEFINE_STATIC(uris_lock);
+AST_RWLOCK_DEFINE_STATIC(uris_lock);
static struct ast_http_uri *uris;
static int httpfd = -1;
@@ -244,7 +244,7 @@
{
struct ast_http_uri *prev;
- ast_mutex_lock(&uris_lock);
+ ast_rwlock_wrlock(&uris_lock);
prev = uris;
if (!uris || strlen(uris->uri) <= strlen(urih->uri)) {
urih->next = uris;
@@ -256,7 +256,7 @@
urih->next = prev->next;
prev->next = urih;
}
- ast_mutex_unlock(&uris_lock);
+ ast_rwlock_unlock(&uris_lock);
return 0;
}
@@ -265,9 +265,9 @@
{
struct ast_http_uri *prev;
- ast_mutex_lock(&uris_lock);
+ ast_rwlock_wrlock(&uris_lock);
if (!uris) {
- ast_mutex_unlock(&uris_lock);
+ ast_rwlock_unlock(&uris_lock);
return;
}
prev = uris;
@@ -281,7 +281,7 @@
}
prev = prev->next;
}
- ast_mutex_unlock(&uris_lock);
+ ast_rwlock_unlock(&uris_lock);
}
static char *handle_uri(struct sockaddr_in *sin, char *uri, int *status, char **title, int *contentlength, struct ast_variable **cookies)
@@ -329,7 +329,7 @@
if (!*uri || (*uri == '/')) {
if (*uri == '/')
uri++;
- ast_mutex_lock(&uris_lock);
+ ast_rwlock_rdlock(&uris_lock);
urih = uris;
while(urih) {
len = strlen(urih->uri);
@@ -347,12 +347,12 @@
urih = urih->next;
}
if (!urih)
- ast_mutex_unlock(&uris_lock);
+ ast_rwlock_unlock(&uris_lock);
}
}
if (urih) {
c = urih->callback(sin, uri, vars, status, title, contentlength);
- ast_mutex_unlock(&uris_lock);
+ ast_rwlock_unlock(&uris_lock);
} else if (ast_strlen_zero(uri) && ast_strlen_zero(prefix)) {
/* Special case: If no prefix, and no URI, send to /static/index.html */
c = ast_http_error(302, "Moved Temporarily", "Location: /static/index.html\r\n", "This is not the page you are looking for...");
@@ -688,7 +688,7 @@
else
ast_cli(fd, "Server Disabled\n\n");
ast_cli(fd, "Enabled URI's:\n");
- ast_mutex_lock(&uris_lock);
+ ast_rwlock_rdlock(&uris_lock);
urih = uris;
while(urih){
ast_cli(fd, "%s/%s%s => %s\n", prefix, urih->uri, (urih->has_subtree ? "/..." : "" ), urih->description);
@@ -696,7 +696,7 @@
}
if (!uris)
ast_cli(fd, "None.\n");
- ast_mutex_unlock(&uris_lock);
+ ast_rwlock_unlock(&uris_lock);
return RESULT_SUCCESS;
}
More information about the asterisk-commits
mailing list