You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by co...@apache.org on 2005/09/29 14:21:02 UTC
svn commit: r292423 - in /httpd/httpd/branches/2.2.x:
modules/cache/cache_storage.c modules/cache/mod_cache.c
modules/cache/mod_cache.h modules/mappers/mod_dir.c server/request.c
Author: colm
Date: Thu Sep 29 05:20:54 2005
New Revision: 292423
URL: http://svn.apache.org/viewcvs?rev=292423&view=rev
Log:
Merge r291588, r291672 and r291914 from trunk; make mod_dir and mod_cache
play nice together.
Modified:
httpd/httpd/branches/2.2.x/modules/cache/cache_storage.c
httpd/httpd/branches/2.2.x/modules/cache/mod_cache.c
httpd/httpd/branches/2.2.x/modules/cache/mod_cache.h
httpd/httpd/branches/2.2.x/modules/mappers/mod_dir.c
httpd/httpd/branches/2.2.x/server/request.c
Modified: httpd/httpd/branches/2.2.x/modules/cache/cache_storage.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.2.x/modules/cache/cache_storage.c?rev=292423&r1=292422&r2=292423&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/cache/cache_storage.c (original)
+++ httpd/httpd/branches/2.2.x/modules/cache/cache_storage.c Thu Sep 29 05:20:54 2005
@@ -66,7 +66,7 @@
* decide whether or not it wants to cache this particular entity.
* If the size is unknown, a size of -1 should be set.
*/
-int cache_create_entity(request_rec *r, char *url, apr_off_t size)
+int cache_create_entity(request_rec *r, apr_off_t size)
{
cache_provider_list *list;
cache_handle_t *h = apr_pcalloc(r->pool, sizeof(cache_handle_t));
Modified: httpd/httpd/branches/2.2.x/modules/cache/mod_cache.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.2.x/modules/cache/mod_cache.c?rev=292423&r1=292422&r2=292423&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/cache/mod_cache.c (original)
+++ httpd/httpd/branches/2.2.x/modules/cache/mod_cache.c Thu Sep 29 05:20:54 2005
@@ -110,14 +110,15 @@
if (rv == DECLINED) {
if (!lookup) {
ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server,
- "Adding CACHE_SAVE filter.");
+ "Adding CACHE_SAVE filter for %s", r->uri);
/* add cache_save filter to cache this request */
ap_add_output_filter_handle(cache_save_filter_handle, NULL, r,
r->connection);
ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server,
- "Adding CACHE_REMOVE_URL filter.");
+ "Adding CACHE_REMOVE_URL filter for %s",
+ r->uri);
/* Add cache_remove_url filter to this request to remove a
* stale cache entry if needed. Also put the current cache
@@ -129,11 +130,17 @@
ap_add_output_filter_handle(cache_remove_url_filter_handle,
cache, r, r->connection);
}
- else if (cache->stale_headers) {
- ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server,
- "Restoring request headers.");
-
- r->headers_in = cache->stale_headers;
+ else {
+ if (cache->stale_headers) {
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS,
+ r->server, "Restoring request headers for %s",
+ r->uri);
+
+ r->headers_in = cache->stale_headers;
+ }
+
+ /* Delete our per-request configuration. */
+ ap_set_module_config(r->request_config, &cache_module, NULL);
}
}
else {
@@ -144,9 +151,29 @@
}
return DECLINED;
}
+
+ /* if we are a lookup, we are exiting soon one way or another; Restore
+ * the headers. */
+ if (lookup) {
+ if (cache->stale_headers) {
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server,
+ "Restoring request headers.");
+ r->headers_in = cache->stale_headers;
+ }
+
+ /* Delete our per-request configuration. */
+ ap_set_module_config(r->request_config, &cache_module, NULL);
+ }
rv = ap_meets_conditions(r);
if (rv != OK) {
+ /* If we are a lookup, we have to return DECLINED as we have no
+ * way of knowing if we will be able to serve the content.
+ */
+ if (lookup) {
+ return DECLINED;
+ }
+
/* Return cached status. */
return rv;
}
@@ -245,7 +272,6 @@
request_rec *r = f->r;
cache_request_rec *cache;
cache_server_conf *conf;
- char *url = r->unparsed_uri;
const char *cc_out, *cl;
const char *exps, *lastmods, *dates, *etag;
apr_time_t exp, date, lastmod, now;
@@ -445,7 +471,8 @@
if (reason) {
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "cache: %s not cached. Reason: %s", url, reason);
+ "cache: %s not cached. Reason: %s", r->unparsed_uri,
+ reason);
/* remove this filter from the chain */
ap_remove_output_filter(f);
@@ -531,7 +558,7 @@
/* no cache handle, create a new entity */
if (!cache->handle) {
- rv = cache_create_entity(r, url, size);
+ rv = cache_create_entity(r, size);
info = apr_pcalloc(r->pool, sizeof(cache_info));
/* We only set info->status upon the initial creation. */
info->status = r->status;
@@ -544,7 +571,7 @@
}
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "cache: Caching url: %s", url);
+ "cache: Caching url: %s", r->unparsed_uri);
/* We are actually caching this response. So it does not
* make sense to remove this entity any more.
Modified: httpd/httpd/branches/2.2.x/modules/cache/mod_cache.h
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.2.x/modules/cache/mod_cache.h?rev=292423&r1=292422&r2=292423&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/cache/mod_cache.h (original)
+++ httpd/httpd/branches/2.2.x/modules/cache/mod_cache.h Thu Sep 29 05:20:54 2005
@@ -212,15 +212,15 @@
/* per request cache information */
typedef struct {
- cache_provider_list *providers; /* possible cache providers */
- const cache_provider *provider; /* current cache provider */
- const char *provider_name; /* current cache provider name */
- int fresh; /* is the entitey fresh? */
- cache_handle_t *handle; /* current cache handle */
- cache_handle_t *stale_handle; /* stale cache handle */
- apr_table_t *stale_headers; /* original request headers. */
- int in_checked; /* CACHE_SAVE must cache the entity */
- int block_response; /* CACHE_SAVE must block response. */
+ cache_provider_list *providers; /* possible cache providers */
+ const cache_provider *provider; /* current cache provider */
+ const char *provider_name; /* current cache provider name */
+ int fresh; /* is the entitey fresh? */
+ cache_handle_t *handle; /* current cache handle */
+ cache_handle_t *stale_handle; /* stale cache handle */
+ apr_table_t *stale_headers; /* original request headers. */
+ int in_checked; /* CACHE_SAVE must cache the entity */
+ int block_response; /* CACHE_SAVE must block response. */
apr_bucket_brigade *saved_brigade; /* copy of partial response */
apr_off_t saved_size; /* length of saved_brigade */
apr_time_t exp; /* expiration */
@@ -274,7 +274,7 @@
* cache_storage.c
*/
int cache_remove_url(cache_request_rec *cache, apr_pool_t *p);
-int cache_create_entity(request_rec *r, char *url, apr_off_t size);
+int cache_create_entity(request_rec *r, apr_off_t size);
int cache_select(request_rec *r);
apr_status_t cache_generate_key_default( request_rec *r, apr_pool_t*p, char**key );
/**
Modified: httpd/httpd/branches/2.2.x/modules/mappers/mod_dir.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.2.x/modules/mappers/mod_dir.c?rev=292423&r1=292422&r2=292423&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/mappers/mod_dir.c (original)
+++ httpd/httpd/branches/2.2.x/modules/mappers/mod_dir.c Thu Sep 29 05:20:54 2005
@@ -182,8 +182,17 @@
rr = ap_sub_req_lookup_uri(name_ptr, r, NULL);
- /* XXX: (filetype == APR_REG) - we can't use a non-file index??? */
- if ( rr->status == HTTP_OK
+ /* The sub request lookup is very liberal, and the core map_to_storage
+ * handler will almost always result in HTTP_OK as /foo/index.html
+ * may be /foo with PATH_INFO="/index.html", or even / with
+ * PATH_INFO="/foo/index.html". To get around this we insist that the
+ * the index be a regular filetype.
+ *
+ * Another reason is that the core handler also makes the assumption
+ * that if r->finfo is still NULL by the time it gets called, the
+ * file does not exist.
+ */
+ if (rr->status == HTTP_OK
&& ( (rr->handler && !strcmp(rr->handler, "proxy-server"))
|| rr->finfo.filetype == APR_REG)) {
ap_internal_fast_redirect(rr, r);
Modified: httpd/httpd/branches/2.2.x/server/request.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.2.x/server/request.c?rev=292423&r1=292422&r2=292423&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/server/request.c (original)
+++ httpd/httpd/branches/2.2.x/server/request.c Thu Sep 29 05:20:54 2005
@@ -1608,10 +1608,18 @@
/* lookup_uri
* If the content can be served by the quick_handler, we can
* safely bypass request_internal processing.
+ *
+ * If next_filter is NULL we are expecting to be
+ * internal_fast_redirect'ed to the subrequest, or the subrequest will
+ * never be invoked. We need to make sure that the quickhandler is not
+ * invoked by any lookups. Since an internal_fast_redirect will always
+ * occur too late for the quickhandler to handle the request.
*/
- res = ap_run_quick_handler(rnew, 1);
+ if (next_filter) {
+ res = ap_run_quick_handler(rnew, 1);
+ }
- if (res != OK) {
+ if (next_filter == NULL || res != OK) {
if ((res = ap_process_request_internal(rnew))) {
rnew->status = res;
}