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: https://origsvn.digium.com/svn/asterisk/trunk@49026 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
parent
29fd3fa0ac
commit
6d9273d0d8
50
main/http.c
50
main/http.c
|
@ -107,7 +107,7 @@ static struct server_args https_desc = {
|
||||||
.worker_fn = httpd_helper_thread,
|
.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. */
|
/* all valid URIs must be prepended by the string in prefix. */
|
||||||
static char prefix[MAX_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;
|
struct ast_http_uri *uri;
|
||||||
int len = strlen(urih->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 ) {
|
if ( AST_RWLIST_EMPTY(&uris) || strlen(AST_RWLIST_FIRST(&uris)->uri) <= len ) {
|
||||||
AST_LIST_INSERT_HEAD(&uris, urih, entry);
|
AST_RWLIST_INSERT_HEAD(&uris, urih, entry);
|
||||||
AST_LIST_UNLOCK(&uris);
|
AST_RWLIST_UNLOCK(&uris);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
AST_LIST_TRAVERSE(&uris, uri, entry) {
|
AST_RWLIST_TRAVERSE(&uris, uri, entry) {
|
||||||
if ( AST_LIST_NEXT(uri, entry)
|
if ( AST_RWLIST_NEXT(uri, entry)
|
||||||
&& strlen(AST_LIST_NEXT(uri, entry)->uri) <= len ) {
|
&& strlen(AST_RWLIST_NEXT(uri, entry)->uri) <= len ) {
|
||||||
AST_LIST_INSERT_AFTER(&uris, uri, urih, entry);
|
AST_RWLIST_INSERT_AFTER(&uris, uri, urih, entry);
|
||||||
AST_LIST_UNLOCK(&uris);
|
AST_RWLIST_UNLOCK(&uris);
|
||||||
return 0;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ast_http_uri_unlink(struct ast_http_uri *urih)
|
void ast_http_uri_unlink(struct ast_http_uri *urih)
|
||||||
{
|
{
|
||||||
AST_LIST_LOCK(&uris);
|
AST_RWLIST_WRLOCK(&uris);
|
||||||
AST_LIST_REMOVE(&uris, urih, entry);
|
AST_RWLIST_REMOVE(&uris, urih, entry);
|
||||||
AST_LIST_UNLOCK(&uris);
|
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)
|
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] == '/') {
|
if (l && !strncasecmp(uri, prefix, l) && uri[l] == '/') {
|
||||||
uri += l + 1;
|
uri += l + 1;
|
||||||
/* scan registered uris to see if we match one. */
|
/* scan registered uris to see if we match one. */
|
||||||
AST_LIST_LOCK(&uris);
|
AST_RWLIST_RDLOCK(&uris);
|
||||||
AST_LIST_TRAVERSE(&uris, urih, entry) {
|
AST_RWLIST_TRAVERSE(&uris, urih, entry) {
|
||||||
l = strlen(urih->uri);
|
l = strlen(urih->uri);
|
||||||
c = uri + l; /* candidate */
|
c = uri + l; /* candidate */
|
||||||
if (strncasecmp(urih->uri, uri, l) /* no match */
|
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)
|
if (!urih)
|
||||||
AST_LIST_UNLOCK(&uris);
|
AST_RWLIST_UNLOCK(&uris);
|
||||||
}
|
}
|
||||||
if (urih) {
|
if (urih) {
|
||||||
out = urih->callback(sin, uri, vars, status, title, contentlength);
|
out = urih->callback(sin, uri, vars, status, title, contentlength);
|
||||||
AST_LIST_UNLOCK(&uris);
|
AST_RWLIST_UNLOCK(&uris);
|
||||||
} else {
|
} else {
|
||||||
out = ast_http_error(404, "Not Found", NULL,
|
out = ast_http_error(404, "Not Found", NULL,
|
||||||
"The requested URL was not found on this server.");
|
"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_cli(fd, "Enabled URI's:\n");
|
||||||
AST_LIST_LOCK(&uris);
|
AST_RWLIST_RDLOCK(&uris);
|
||||||
AST_LIST_TRAVERSE(&uris, urih, entry)
|
if (AST_RWLIST_EMPTY(&uris)) {
|
||||||
ast_cli(fd, "%s/%s%s => %s\n", prefix, urih->uri, (urih->has_subtree ? "/..." : "" ), urih->description);
|
|
||||||
if (AST_LIST_EMPTY(&uris))
|
|
||||||
ast_cli(fd, "None.\n");
|
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_cli(fd, "\nEnabled Redirects:\n");
|
||||||
AST_LIST_LOCK(&uri_redirects);
|
AST_LIST_LOCK(&uri_redirects);
|
||||||
|
|
Loading…
Reference in New Issue