mirror of
https://github.com/apache/httpd.git
synced 2026-01-06 09:01:14 +03:00
Pass the huge apr_uri_t structs by reference instead of by value
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@982012 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
55
modules/cache/cache_util.c
vendored
55
modules/cache/cache_util.c
vendored
@@ -29,8 +29,9 @@ extern module AP_MODULE_DECLARE_DATA cache_module;
|
||||
/* Determine if "url" matches the hostname, scheme and port and path
|
||||
* in "filter". All but the path comparisons are case-insensitive.
|
||||
*/
|
||||
static int uri_meets_conditions(const apr_uri_t filter, const int pathlen,
|
||||
const apr_uri_t url) {
|
||||
static int uri_meets_conditions(const apr_uri_t *filter, const int pathlen,
|
||||
const apr_uri_t *url)
|
||||
{
|
||||
|
||||
/* Scheme, hostname port and local part. The filter URI and the
|
||||
* URI we test may have the following shapes:
|
||||
@@ -46,14 +47,14 @@ static int uri_meets_conditions(const apr_uri_t filter, const int pathlen,
|
||||
*/
|
||||
|
||||
/* Is the filter is just for a local path or a proxy URI? */
|
||||
if (!filter.scheme) {
|
||||
if (url.scheme || url.hostname) {
|
||||
if (!filter->scheme) {
|
||||
if (url->scheme || url->hostname) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* The URI scheme must be present and identical except for case. */
|
||||
if (!url.scheme || strcasecmp(filter.scheme, url.scheme)) {
|
||||
if (!url->scheme || strcasecmp(filter->scheme, url->scheme)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -63,26 +64,26 @@ static int uri_meets_conditions(const apr_uri_t filter, const int pathlen,
|
||||
* of the URI * hostname including the ".", otherwise it must match
|
||||
* the URI hostname exactly. */
|
||||
|
||||
if (filter.hostname && filter.hostname[0]) {
|
||||
if (filter.hostname[0] == '.') {
|
||||
const size_t fhostlen = strlen(filter.hostname);
|
||||
const size_t uhostlen = url.hostname ? strlen(url.hostname) : 0;
|
||||
if (filter->hostname && filter->hostname[0]) {
|
||||
if (filter->hostname[0] == '.') {
|
||||
const size_t fhostlen = strlen(filter->hostname);
|
||||
const size_t uhostlen = url->hostname ? strlen(url->hostname) : 0;
|
||||
|
||||
if (fhostlen > uhostlen || strcasecmp(filter.hostname,
|
||||
url.hostname + uhostlen - fhostlen)) {
|
||||
if (fhostlen > uhostlen || strcasecmp(filter->hostname,
|
||||
url->hostname + uhostlen - fhostlen)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if (filter.hostname[0] == '*') {
|
||||
const size_t fhostlen = strlen(filter.hostname + 1);
|
||||
const size_t uhostlen = url.hostname ? strlen(url.hostname) : 0;
|
||||
else if (filter->hostname[0] == '*') {
|
||||
const size_t fhostlen = strlen(filter->hostname + 1);
|
||||
const size_t uhostlen = url->hostname ? strlen(url->hostname) : 0;
|
||||
|
||||
if (fhostlen > uhostlen || strcasecmp(filter.hostname + 1,
|
||||
url.hostname + uhostlen - fhostlen)) {
|
||||
if (fhostlen > uhostlen || strcasecmp(filter->hostname + 1,
|
||||
url->hostname + uhostlen - fhostlen)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if (!url.hostname || strcasecmp(filter.hostname, url.hostname)) {
|
||||
else if (!url->hostname || strcasecmp(filter->hostname, url->hostname)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -91,12 +92,12 @@ static int uri_meets_conditions(const apr_uri_t filter, const int pathlen,
|
||||
* If the filter or URL port are missing, or the URL port is
|
||||
* empty, they default to the port for their scheme. */
|
||||
|
||||
if (!(filter.port_str && !filter.port_str[0])) {
|
||||
if (!(filter->port_str && !filter->port_str[0])) {
|
||||
/* NOTE: ap_port_of_scheme will return 0 if given NULL input */
|
||||
const unsigned fport = filter.port_str ? filter.port
|
||||
: apr_uri_port_of_scheme(filter.scheme);
|
||||
const unsigned uport = (url.port_str && url.port_str[0])
|
||||
? url.port : apr_uri_port_of_scheme(url.scheme);
|
||||
const unsigned fport = filter->port_str ? filter->port
|
||||
: apr_uri_port_of_scheme(filter->scheme);
|
||||
const unsigned uport = (url->port_str && url->port_str[0])
|
||||
? url->port : apr_uri_port_of_scheme(url->scheme);
|
||||
|
||||
if (fport != uport) {
|
||||
return 0;
|
||||
@@ -107,8 +108,8 @@ static int uri_meets_conditions(const apr_uri_t filter, const int pathlen,
|
||||
/* For HTTP caching purposes, an empty (NULL) path is equivalent to
|
||||
* a single "/" path. RFCs 3986/2396
|
||||
*/
|
||||
if (!url.path) {
|
||||
if (*filter.path == '/' && pathlen == 1) {
|
||||
if (!url->path) {
|
||||
if (*filter->path == '/' && pathlen == 1) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
@@ -119,7 +120,7 @@ static int uri_meets_conditions(const apr_uri_t filter, const int pathlen,
|
||||
/* Url has met all of the filter conditions so far, determine
|
||||
* if the paths match.
|
||||
*/
|
||||
return !strncmp(filter.path, url.path, pathlen);
|
||||
return !strncmp(filter->path, url->path, pathlen);
|
||||
}
|
||||
|
||||
CACHE_DECLARE(cache_provider_list *)ap_cache_get_providers(request_rec *r,
|
||||
@@ -133,7 +134,7 @@ CACHE_DECLARE(cache_provider_list *)ap_cache_get_providers(request_rec *r,
|
||||
for (i = 0; i < conf->cacheenable->nelts; i++) {
|
||||
struct cache_enable *ent =
|
||||
(struct cache_enable *)conf->cacheenable->elts;
|
||||
if (uri_meets_conditions(ent[i].url, ent[i].pathlen, uri)) {
|
||||
if (uri_meets_conditions(&ent[i].url, ent[i].pathlen, &uri)) {
|
||||
/* Fetch from global config and add to the list. */
|
||||
cache_provider *provider;
|
||||
provider = ap_lookup_provider(CACHE_PROVIDER_GROUP, ent[i].type,
|
||||
@@ -170,7 +171,7 @@ CACHE_DECLARE(cache_provider_list *)ap_cache_get_providers(request_rec *r,
|
||||
for (i = 0; i < conf->cachedisable->nelts; i++) {
|
||||
struct cache_disable *ent =
|
||||
(struct cache_disable *)conf->cachedisable->elts;
|
||||
if (uri_meets_conditions(ent[i].url, ent[i].pathlen, uri)) {
|
||||
if (uri_meets_conditions(&ent[i].url, ent[i].pathlen, &uri)) {
|
||||
/* Stop searching now. */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user