diff options
| author | Stefan Fritsch <sf@sfritsch.de> | 2015-04-28 22:06:31 +0200 |
|---|---|---|
| committer | Stefan Fritsch <sf@sfritsch.de> | 2015-04-28 22:06:31 +0200 |
| commit | 080d5e16db802902200a9ce5b6c40f8f1fdc1f73 (patch) | |
| tree | 69845ca856fe6817f103544e88541d80411fe9a8 /modules/cache | |
| parent | cb35beef2a938b80c9e4b5d6a408eca437aa74db (diff) | |
| download | apache2-080d5e16db802902200a9ce5b6c40f8f1fdc1f73.tar.gz | |
Imported Upstream version 2.4.12
Diffstat (limited to 'modules/cache')
| -rw-r--r-- | modules/cache/cache_util.c | 10 | ||||
| -rw-r--r-- | modules/cache/mod_cache.c | 14 | ||||
| -rw-r--r-- | modules/cache/mod_cache_socache.c | 58 | ||||
| -rw-r--r-- | modules/cache/mod_cache_socache.dsp | 4 |
4 files changed, 74 insertions, 12 deletions
diff --git a/modules/cache/cache_util.c b/modules/cache/cache_util.c index bf450931..b7454ad6 100644 --- a/modules/cache/cache_util.c +++ b/modules/cache/cache_util.c @@ -443,7 +443,7 @@ int ap_cache_check_no_cache(cache_request_rec *cache, request_rec *r) return 0; } else { - ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, + ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(02657) "Incoming request is asking for an uncached version of " "%s, but we have been configured to ignore it and serve " "cached content anyway", r->unparsed_uri); @@ -483,7 +483,7 @@ int ap_cache_check_no_store(cache_request_rec *cache, request_rec *r) return 0; } else { - ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, + ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(02658) "Incoming request is asking for a no-store version of " "%s, but we have been configured to ignore it and serve " "cached content anyway", r->unparsed_uri); @@ -1258,8 +1258,10 @@ apr_table_t *cache_merge_headers_out(request_rec *r) if (r->content_type && !apr_table_get(headers_out, "Content-Type")) { - apr_table_setn(headers_out, "Content-Type", - ap_make_content_type(r, r->content_type)); + const char *ctype = ap_make_content_type(r, r->content_type); + if (ctype) { + apr_table_setn(headers_out, "Content-Type", ctype); + } } if (r->content_encoding diff --git a/modules/cache/mod_cache.c b/modules/cache/mod_cache.c index cd839ed7..b95f0a8a 100644 --- a/modules/cache/mod_cache.c +++ b/modules/cache/mod_cache.c @@ -234,6 +234,11 @@ static int cache_quick_handler(request_rec *r, int lookup) ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r, APLOGNO(00752) "Cache locked for url, not caching " "response: %s", r->uri); + /* cache_select() may have added conditional headers */ + if (cache->stale_headers) { + r->headers_in = cache->stale_headers; + } + } } else { @@ -636,7 +641,6 @@ static int cache_handler(request_rec *r) static apr_status_t cache_out_filter(ap_filter_t *f, apr_bucket_brigade *in) { request_rec *r = f->r; - apr_bucket *e; cache_request_rec *cache = (cache_request_rec *)f->ctx; if (!cache) { @@ -652,10 +656,8 @@ static apr_status_t cache_out_filter(ap_filter_t *f, apr_bucket_brigade *in) "cache: running CACHE_OUT filter"); /* clean out any previous response up to EOS, if any */ - for (e = APR_BRIGADE_FIRST(in); - e != APR_BRIGADE_SENTINEL(in); - e = APR_BUCKET_NEXT(e)) - { + while (!APR_BRIGADE_EMPTY(in)) { + apr_bucket *e = APR_BRIGADE_FIRST(in); if (APR_BUCKET_IS_EOS(e)) { apr_bucket_brigade *bb = apr_brigade_create(r->pool, r->connection->bucket_alloc); @@ -1201,6 +1203,8 @@ static apr_status_t cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in) apr_table_unset(r->headers_in, "If-Range"); apr_table_unset(r->headers_in, "If-Unmodified-Since"); + /* Currently HTTP_NOT_MODIFIED, and after the redirect, handlers won't think to set status to HTTP_OK */ + r->status = HTTP_OK; ap_internal_redirect(r->unparsed_uri, r); return APR_SUCCESS; diff --git a/modules/cache/mod_cache_socache.c b/modules/cache/mod_cache_socache.c index a138e6b8..6bd9466b 100644 --- a/modules/cache/mod_cache_socache.c +++ b/modules/cache/mod_cache_socache.c @@ -22,6 +22,7 @@ #include "http_config.h" #include "http_log.h" #include "http_core.h" +#include "http_protocol.h" #include "ap_provider.h" #include "ap_socache.h" #include "util_filter.h" @@ -30,6 +31,7 @@ #include "util_mutex.h" #include "mod_cache.h" +#include "mod_status.h" #include "cache_socache_common.h" @@ -1375,6 +1377,56 @@ static apr_status_t destroy_cache(void *data) return APR_SUCCESS; } +static int socache_status_hook(request_rec *r, int flags) +{ + apr_status_t status = APR_SUCCESS; + cache_socache_conf *conf = ap_get_module_config(r->server->module_config, + &cache_socache_module); + if (!conf->provider || !conf->provider->socache_provider || + !conf->provider->socache_instance) { + return DECLINED; + } + + ap_rputs("<hr>\n" + "<table cellspacing=0 cellpadding=0>\n" + "<tr><td bgcolor=\"#000000\">\n" + "<b><font color=\"#ffffff\" face=\"Arial,Helvetica\">" + "mod_cache_socache Status:</font></b>\n" + "</td></tr>\n" + "<tr><td bgcolor=\"#ffffff\">\n", r); + + if (socache_mutex) { + status = apr_global_mutex_lock(socache_mutex); + if (status != APR_SUCCESS) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, APLOGNO(02816) + "could not acquire lock for cache status"); + } + } + + if (status != APR_SUCCESS) { + ap_rputs("No cache status data available\n", r); + } else { + conf->provider->socache_provider->status(conf->provider->socache_instance, + r, flags); + } + + if (socache_mutex && status == APR_SUCCESS) { + status = apr_global_mutex_unlock(socache_mutex); + if (status != APR_SUCCESS) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, APLOGNO(02817) + "could not release lock for cache status"); + } + } + + ap_rputs("</td></tr>\n</table>\n", r); + return OK; +} + +static void socache_status_register(apr_pool_t *p) +{ + APR_OPTIONAL_HOOK(ap, status_hook, socache_status_hook, NULL, NULL, APR_HOOK_MIDDLE); +} + static int socache_precfg(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptmp) { apr_status_t rv = ap_mutex_register(pconf, cache_socache_id, NULL, @@ -1384,6 +1436,10 @@ static int socache_precfg(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptmp) "failed to register %s mutex", cache_socache_id); return 500; /* An HTTP status would be a misnomer! */ } + + /* Register to handle mod_status status page generation */ + socache_status_register(pconf); + return OK; } @@ -1394,7 +1450,7 @@ static int socache_post_config(apr_pool_t *pconf, apr_pool_t *plog, apr_status_t rv; const char *errmsg; static struct ap_socache_hints socache_hints = - { 64, 32, 60000000 }; + { 64, 2048, 60000000 }; for (s = base_server; s; s = s->next) { cache_socache_conf *conf = diff --git a/modules/cache/mod_cache_socache.dsp b/modules/cache/mod_cache_socache.dsp index e5d582e2..1dd82145 100644 --- a/modules/cache/mod_cache_socache.dsp +++ b/modules/cache/mod_cache_socache.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c -# ADD CPP /nologo /MD /W3 /O2 /Oy- /Zi /I "../../srclib/apr-util/include" /I "../../srclib/apr/include" /I "../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fd"Release\mod_cache_socache_src" /FD /c +# ADD CPP /nologo /MD /W3 /O2 /Oy- /Zi /I "../../srclib/apr-util/include" /I "../../srclib/apr/include" /I "../../include" /I "../generators" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fd"Release\mod_cache_socache_src" /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "NDEBUG" @@ -75,7 +75,7 @@ PostBuild_Cmds=if exist $(TargetPath).manifest mt.exe -manifest $(TargetPath).ma # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c -# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "../../srclib/apr-util/include" /I "../../srclib/apr/include" /I "../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /Fd"Debug\mod_cache_socache_src" /FD /c +# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "../../srclib/apr-util/include" /I "../../srclib/apr/include" /I "../../include" /I "../generators" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /Fd"Debug\mod_cache_socache_src" /FD /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "_DEBUG" |
