[asterisk-commits] file: trunk r49027 - /trunk/main/http.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Thu Dec 28 13:05:01 MST 2006
Author: file
Date: Thu Dec 28 14:05:00 2006
New Revision: 49027
URL: http://svn.digium.com/view/asterisk?view=rev&rev=49027
Log:
Convert uri_redirects list to read/write locks.
Modified:
trunk/main/http.c
Modified: trunk/main/http.c
URL: http://svn.digium.com/view/asterisk/trunk/main/http.c?view=diff&rev=49027&r1=49026&r2=49027
==============================================================================
--- trunk/main/http.c (original)
+++ trunk/main/http.c Thu Dec 28 14:05:00 2006
@@ -131,7 +131,7 @@
char target[0];
};
-static AST_LIST_HEAD_STATIC(uri_redirects, http_uri_redirect);
+static AST_RWLIST_HEAD_STATIC(uri_redirects, http_uri_redirect);
static char *ftype2mtype(const char *ftype, char *wkspace, int wkspacelen)
{
@@ -383,8 +383,8 @@
*cookies = NULL;
ast_uri_decode(uri);
- AST_LIST_LOCK(&uri_redirects);
- AST_LIST_TRAVERSE(&uri_redirects, redirect, entry) {
+ AST_RWLIST_RDLOCK(&uri_redirects);
+ AST_RWLIST_TRAVERSE(&uri_redirects, redirect, entry) {
if (!strcasecmp(uri, redirect->target)) {
char buf[512];
snprintf(buf, sizeof(buf), "Location: %s\r\n", redirect->dest);
@@ -395,7 +395,7 @@
break;
}
}
- AST_LIST_UNLOCK(&uri_redirects);
+ AST_RWLIST_UNLOCK(&uri_redirects);
if (redirect)
goto cleanup;
@@ -837,28 +837,28 @@
strcpy(redirect->target, target);
strcpy(redirect->dest, dest);
- AST_LIST_LOCK(&uri_redirects);
+ AST_RWLIST_WRLOCK(&uri_redirects);
target_len--; /* So we can compare directly with strlen() */
- if ( AST_LIST_EMPTY(&uri_redirects)
- || strlen(AST_LIST_FIRST(&uri_redirects)->target) <= target_len ) {
- AST_LIST_INSERT_HEAD(&uri_redirects, redirect, entry);
- AST_LIST_UNLOCK(&uri_redirects);
+ if ( AST_RWLIST_EMPTY(&uri_redirects)
+ || strlen(AST_RWLIST_FIRST(&uri_redirects)->target) <= target_len ) {
+ AST_RWLIST_INSERT_HEAD(&uri_redirects, redirect, entry);
+ AST_RWLIST_UNLOCK(&uri_redirects);
return;
}
- AST_LIST_TRAVERSE(&uri_redirects, cur, entry) {
- if ( AST_LIST_NEXT(cur, entry)
- && strlen(AST_LIST_NEXT(cur, entry)->target) <= target_len ) {
- AST_LIST_INSERT_AFTER(&uri_redirects, cur, redirect, entry);
- AST_LIST_UNLOCK(&uri_redirects);
+ AST_RWLIST_TRAVERSE(&uri_redirects, cur, entry) {
+ if ( AST_RWLIST_NEXT(cur, entry)
+ && strlen(AST_RWLIST_NEXT(cur, entry)->target) <= target_len ) {
+ AST_RWLIST_INSERT_AFTER(&uri_redirects, cur, redirect, entry);
+ AST_RWLIST_UNLOCK(&uri_redirects);
return;
}
}
- AST_LIST_INSERT_TAIL(&uri_redirects, redirect, entry);
-
- AST_LIST_UNLOCK(&uri_redirects);
+ AST_RWLIST_INSERT_TAIL(&uri_redirects, redirect, entry);
+
+ AST_RWLIST_UNLOCK(&uri_redirects);
}
static int __ast_http_load(int reload)
@@ -889,10 +889,10 @@
free(http_tls_cfg.cipher);
http_tls_cfg.cipher = ast_strdup("");
- AST_LIST_LOCK(&uri_redirects);
- while ((redirect = AST_LIST_REMOVE_HEAD(&uri_redirects, entry)))
+ AST_RWLIST_WRLOCK(&uri_redirects);
+ while ((redirect = AST_RWLIST_REMOVE_HEAD(&uri_redirects, entry)))
free(redirect);
- AST_LIST_UNLOCK(&uri_redirects);
+ AST_RWLIST_UNLOCK(&uri_redirects);
cfg = ast_config_load("http.conf");
if (cfg) {
@@ -989,12 +989,12 @@
AST_RWLIST_UNLOCK(&uris);
ast_cli(fd, "\nEnabled Redirects:\n");
- AST_LIST_LOCK(&uri_redirects);
- AST_LIST_TRAVERSE(&uri_redirects, redirect, entry)
+ AST_RWLIST_RDLOCK(&uri_redirects);
+ AST_RWLIST_TRAVERSE(&uri_redirects, redirect, entry)
ast_cli(fd, " %s => %s\n", redirect->target, redirect->dest);
- if (AST_LIST_EMPTY(&uri_redirects))
+ if (AST_RWLIST_EMPTY(&uri_redirects))
ast_cli(fd, " None.\n");
- AST_LIST_UNLOCK(&uri_redirects);
+ AST_RWLIST_UNLOCK(&uri_redirects);
return RESULT_SUCCESS;
}
More information about the asterisk-commits
mailing list