aboutsummaryrefslogtreecommitdiffstats
path: root/main/http.c
diff options
context:
space:
mode:
authorfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2006-12-28 20:02:41 +0000
committerfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2006-12-28 20:02:41 +0000
commit7aff08fedbd3e9075800c4c30d2075b35dfc308e (patch)
tree645289898ea77ab3d7a52340ee0b83e8628e7361 /main/http.c
parent553307308a615a2dde544f611af2a71f1aee1f36 (diff)
Merged revisions 49024 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r49024 | qwell | 2006-12-28 14:52:46 -0500 (Thu, 28 Dec 2006) | 2 lines make the uris_lock a rwlock instead of a mutex lock - needs to be forward ported to trunk ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@49026 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/http.c')
-rw-r--r--main/http.c50
1 files changed, 26 insertions, 24 deletions
diff --git a/main/http.c b/main/http.c
index c350368d7..8def00163 100644
--- a/main/http.c
+++ b/main/http.c
@@ -107,7 +107,7 @@ static struct server_args https_desc = {
.worker_fn = httpd_helper_thread,
};
-static AST_LIST_HEAD_STATIC(uris, ast_http_uri); /*!< list of supported handlers */
+static AST_RWLIST_HEAD_STATIC(uris, ast_http_uri); /*!< list of supported handlers */
/* all valid URIs must be prepended by the string in prefix. */
static char prefix[MAX_PREFIX];
@@ -309,35 +309,35 @@ int ast_http_uri_link(struct ast_http_uri *urih)
struct ast_http_uri *uri;
int len = strlen(urih->uri);
- AST_LIST_LOCK(&uris);
+ AST_RWLIST_WRLOCK(&uris);
- if ( AST_LIST_EMPTY(&uris) || strlen(AST_LIST_FIRST(&uris)->uri) <= len ) {
- AST_LIST_INSERT_HEAD(&uris, urih, entry);
- AST_LIST_UNLOCK(&uris);
+ if ( AST_RWLIST_EMPTY(&uris) || strlen(AST_RWLIST_FIRST(&uris)->uri) <= len ) {
+ AST_RWLIST_INSERT_HEAD(&uris, urih, entry);
+ AST_RWLIST_UNLOCK(&uris);
return 0;
}
- AST_LIST_TRAVERSE(&uris, uri, entry) {
- if ( AST_LIST_NEXT(uri, entry)
- && strlen(AST_LIST_NEXT(uri, entry)->uri) <= len ) {
- AST_LIST_INSERT_AFTER(&uris, uri, urih, entry);
- AST_LIST_UNLOCK(&uris);
+ AST_RWLIST_TRAVERSE(&uris, uri, entry) {
+ if ( AST_RWLIST_NEXT(uri, entry)
+ && strlen(AST_RWLIST_NEXT(uri, entry)->uri) <= len ) {
+ AST_RWLIST_INSERT_AFTER(&uris, uri, urih, entry);
+ AST_RWLIST_UNLOCK(&uris);
return 0;
}
}
- AST_LIST_INSERT_TAIL(&uris, urih, entry);
+ AST_RWLIST_INSERT_TAIL(&uris, urih, entry);
- AST_LIST_UNLOCK(&uris);
+ AST_RWLIST_UNLOCK(&uris);
return 0;
}
void ast_http_uri_unlink(struct ast_http_uri *urih)
{
- AST_LIST_LOCK(&uris);
- AST_LIST_REMOVE(&uris, urih, entry);
- AST_LIST_UNLOCK(&uris);
+ AST_RWLIST_WRLOCK(&uris);
+ AST_RWLIST_REMOVE(&uris, urih, entry);
+ AST_RWLIST_UNLOCK(&uris);
}
static struct ast_str *handle_uri(struct sockaddr_in *sin, char *uri, int *status, char **title, int *contentlength, struct ast_variable **cookies)
@@ -404,8 +404,8 @@ static struct ast_str *handle_uri(struct sockaddr_in *sin, char *uri, int *statu
if (l && !strncasecmp(uri, prefix, l) && uri[l] == '/') {
uri += l + 1;
/* scan registered uris to see if we match one. */
- AST_LIST_LOCK(&uris);
- AST_LIST_TRAVERSE(&uris, urih, entry) {
+ AST_RWLIST_RDLOCK(&uris);
+ AST_RWLIST_TRAVERSE(&uris, urih, entry) {
l = strlen(urih->uri);
c = uri + l; /* candidate */
if (strncasecmp(urih->uri, uri, l) /* no match */
@@ -419,11 +419,11 @@ static struct ast_str *handle_uri(struct sockaddr_in *sin, char *uri, int *statu
}
}
if (!urih)
- AST_LIST_UNLOCK(&uris);
+ AST_RWLIST_UNLOCK(&uris);
}
if (urih) {
out = urih->callback(sin, uri, vars, status, title, contentlength);
- AST_LIST_UNLOCK(&uris);
+ AST_RWLIST_UNLOCK(&uris);
} else {
out = ast_http_error(404, "Not Found", NULL,
"The requested URL was not found on this server.");
@@ -979,12 +979,14 @@ static int handle_show_http(int fd, int argc, char *argv[])
}
ast_cli(fd, "Enabled URI's:\n");
- AST_LIST_LOCK(&uris);
- AST_LIST_TRAVERSE(&uris, urih, entry)
- ast_cli(fd, "%s/%s%s => %s\n", prefix, urih->uri, (urih->has_subtree ? "/..." : "" ), urih->description);
- if (AST_LIST_EMPTY(&uris))
+ AST_RWLIST_RDLOCK(&uris);
+ if (AST_RWLIST_EMPTY(&uris)) {
ast_cli(fd, "None.\n");
- AST_LIST_UNLOCK(&uris);
+ } else {
+ AST_RWLIST_TRAVERSE(&uris, urih, entry)
+ ast_cli(fd, "%s/%s%s => %s\n", prefix, urih->uri, (urih->has_subtree ? "/..." : "" ), urih->description);
+ }
+ AST_RWLIST_UNLOCK(&uris);
ast_cli(fd, "\nEnabled Redirects:\n");
AST_LIST_LOCK(&uri_redirects);