]> granicus.if.org Git - apache/commitdiff
mod_cache cleanup:
authorJeff Trawick <trawick@apache.org>
Thu, 23 Aug 2001 19:46:55 +0000 (19:46 +0000)
committerJeff Trawick <trawick@apache.org>
Thu, 23 Aug 2001 19:46:55 +0000 (19:46 +0000)
change the module variable from tcache_module to cache_module

clear up various gcc warnings

don't segfault when the silly user (me) configures CACHE_OUT
manually

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@90579 13f79535-47bb-0310-9956-ffa450edef68

modules/experimental/cache_storage.c
modules/experimental/mod_cache.c
modules/experimental/mod_cache.h

index 050628dad1e2b8d1c9e34c78aaf30b8ab3304ca7..8184db5f4df30cd67312820b4224e19a6b088a04 100644 (file)
@@ -66,7 +66,7 @@ APR_HOOK_STRUCT(
        APR_HOOK_LINK(open_entity)
 )
 
-module AP_MODULE_DECLARE_DATA tcache_module;
+module AP_MODULE_DECLARE_DATA cache_module;
 
 /* -------------------------------------------------------------- */
 
@@ -105,7 +105,7 @@ int cache_create_entity(request_rec *r, const char *types, char *url, apr_size_t
     const char *type;
     apr_status_t rv;
     cache_request_rec *cache = (cache_request_rec *) ap_get_module_config(r->request_config, 
-                                                                          &tcache_module);
+                                                                          &cache_module);
 
     /* for each specified cache type, delete the URL */
     while (next) {
@@ -161,7 +161,7 @@ int cache_select_url(request_rec *r, const char *types, char *url)
     const char *type;
     apr_status_t rv;
     cache_request_rec *cache = (cache_request_rec *) ap_get_module_config(r->request_config, 
-                                                                          &tcache_module);
+                                                                          &cache_module);
 
     /* go through the cache types till we get a match */
     while (next) {
@@ -219,7 +219,8 @@ apr_status_t cache_read_entity_headers(cache_handle *h, request_rec *r,
     *headers = apr_table_make(r->pool, 15);
     /* Content-Length */
     if (info->len)
-        apr_table_set(*headers, "Content-Length", apr_psprintf(r->pool, "%lu", info->len));
+        apr_table_set(*headers, "Content-Length", 
+                      apr_psprintf(r->pool, "%" APR_SIZE_T_FMT, info->len));
 
     /* Last-Modified */
     if (info->lastmod) {
index 9b18670dda83cc24e4761a36ea9f783af9faa132..071ffdba57b83a40ed2f16d1c1b444dc03d4821b 100644 (file)
@@ -60,7 +60,7 @@
 
 #include "mod_cache.h"
 
-module AP_MODULE_DECLARE_DATA tcache_module;
+module AP_MODULE_DECLARE_DATA cache_module;
 
 
 
@@ -89,7 +89,6 @@ int ap_url_cache_handler(request_rec *r)
 {
     apr_status_t rv;
     const char *cc_in;
-    apr_pool_t *p = r->pool;
     apr_uri_t uri = r->parsed_uri;
     char *url = r->unparsed_uri;
     char *path = uri.path;
@@ -97,7 +96,7 @@ int ap_url_cache_handler(request_rec *r)
     cache_info *info = NULL;
     cache_request_rec *cache;
     cache_server_conf *conf = (cache_server_conf *) ap_get_module_config(r->server->module_config, 
-                                                                         &tcache_module);
+                                                                         &cache_module);
 
     /* we don't handle anything but GET */
     if (r->method_number != M_GET) return DECLINED;
@@ -112,10 +111,10 @@ int ap_url_cache_handler(request_rec *r)
                  "cache: URL %s is being handled by %s", path, types);
 
     /* make space for the per request config */
-    cache = (cache_request_rec *) ap_get_module_config(r->request_config, &tcache_module);
+    cache = (cache_request_rec *) ap_get_module_config(r->request_config, &cache_module);
     if (!cache) {
         cache = ap_pcalloc(r->pool, sizeof(cache_request_rec));
-        ap_set_module_config(r->request_config, &tcache_module, cache);
+        ap_set_module_config(r->request_config, &cache_module, cache);
     }
 
     /* save away the type */
@@ -273,11 +272,19 @@ int ap_cache_out_filter(ap_filter_t *f, apr_bucket_brigade *bb);
 
 int ap_cache_out_filter(ap_filter_t *f, apr_bucket_brigade *bb)
 {
-    cache_info *info = NULL;
     request_rec *r = f->r;
     apr_table_t *headers;
     cache_request_rec *cache = (cache_request_rec *) ap_get_module_config(r->request_config, 
-                                                                          &tcache_module);
+                                                                          &cache_module);
+
+    if (!cache) {
+        /* user likely configured CACHE_OUT manually; they should use mod_cache
+         * configuration to do that */
+        ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+                     "CACHE_OUT enabled unexpectedly");
+        ap_remove_output_filter(f);
+        return ap_pass_brigade(f->next, bb);
+    }
 
     ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, 0, r->server,
                 "cache: running CACHE_OUT filter");
@@ -341,24 +348,18 @@ int ap_cache_in_filter(ap_filter_t *f, apr_bucket_brigade *in);
 int ap_cache_in_filter(ap_filter_t *f, apr_bucket_brigade *in)
 {
     request_rec *r = f->r;
-    apr_uri_t uri = r->parsed_uri;
     char *url = r->unparsed_uri;
-    apr_pool_t *p = r->pool;
-    apr_bucket *e;
-    apr_bucket_brigade *out = apr_brigade_create(p);
-
     const char *cc_out = ap_table_get(r->headers_out, "Cache-Control");
     const char *exps, *lastmods, *dates, *etag;
     apr_time_t exp, date, lastmod, now;
     apr_size_t size;
-
     cache_info *info;
     void *sconf = r->server->module_config;
     cache_server_conf *conf =
-    (cache_server_conf *) ap_get_module_config(sconf, &tcache_module);
+    (cache_server_conf *) ap_get_module_config(sconf, &cache_module);
     void *scache = r->request_config;
     cache_request_rec *cache =
-    (cache_request_rec *) ap_get_module_config(scache, &tcache_module);
+    (cache_request_rec *) ap_get_module_config(scache, &cache_module);
 
 
     ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, 0, f->r->server,
@@ -670,7 +671,7 @@ static void * merge_cache_config(apr_pool_t *p, void *basev, void *overridesv)
 static const char
 *set_cache_on(cmd_parms *parms, void *dummy, int flag)
 {
-    cache_server_conf *conf = ap_get_module_config(parms->server->module_config, &tcache_module);
+    cache_server_conf *conf = ap_get_module_config(parms->server->module_config, &cache_module);
 
     conf->cacheon = 1;
     conf->cacheon_set = 1;
@@ -680,7 +681,7 @@ static const char
 static const char
 *add_cache_enable(cmd_parms *parms, void *dummy, const char *type, const char *url)
 {
-    cache_server_conf *conf = ap_get_module_config(parms->server->module_config, &tcache_module);
+    cache_server_conf *conf = ap_get_module_config(parms->server->module_config, &cache_module);
     struct cache_enable *new;
 
     new = apr_array_push(conf->cacheenable);
@@ -692,7 +693,7 @@ static const char
 static const char
 *add_cache_disable(cmd_parms *parms, void *dummy, const char *url)
 {
-    cache_server_conf *conf = ap_get_module_config(parms->server->module_config, &tcache_module);
+    cache_server_conf *conf = ap_get_module_config(parms->server->module_config, &cache_module);
     struct cache_enable *new;
 
     new = apr_array_push(conf->cachedisable);
@@ -703,7 +704,7 @@ static const char
 static const char
 *set_cache_maxex(cmd_parms *parms, void *dummy, const char *arg)
 {
-    cache_server_conf *conf = ap_get_module_config(parms->server->module_config, &tcache_module);
+    cache_server_conf *conf = ap_get_module_config(parms->server->module_config, &cache_module);
     double val;
 
     if (sscanf(arg, "%lg", &val) != 1)
@@ -716,7 +717,7 @@ static const char
 static const char
 *set_cache_defex(cmd_parms *parms, void *dummy, const char *arg)
 {
-    cache_server_conf *conf = ap_get_module_config(parms->server->module_config, &tcache_module);
+    cache_server_conf *conf = ap_get_module_config(parms->server->module_config, &cache_module);
     double val;
 
     if (sscanf(arg, "%lg", &val) != 1)
@@ -729,7 +730,7 @@ static const char
 static const char
 *set_cache_factor(cmd_parms *parms, void *dummy, const char *arg)
 {
-    cache_server_conf *conf = ap_get_module_config(parms->server->module_config, &tcache_module);
+    cache_server_conf *conf = ap_get_module_config(parms->server->module_config, &cache_module);
     double val;
 
     if (sscanf(arg, "%lg", &val) != 1)
@@ -742,7 +743,7 @@ static const char
 static const char
 *set_cache_complete(cmd_parms *parms, void *dummy, const char *arg)
 {
-    cache_server_conf *conf = ap_get_module_config(parms->server->module_config, &tcache_module);
+    cache_server_conf *conf = ap_get_module_config(parms->server->module_config, &cache_module);
     int val;
 
     if (sscanf(arg, "%u", &val) != 1)
@@ -792,7 +793,7 @@ register_hooks(apr_pool_t *p)
     ap_register_output_filter("CACHE_CONDITIONAL", ap_cache_conditional_filter, AP_FTYPE_NETWORK);
 }
 
-module AP_MODULE_DECLARE_DATA tcache_module =
+module AP_MODULE_DECLARE_DATA cache_module =
 {
     STANDARD20_MODULE_STUFF,
     NULL,                      /* create per-directory config structure */
@@ -802,4 +803,3 @@ module AP_MODULE_DECLARE_DATA tcache_module =
     cache_cmds,                        /* command apr_table_t */
     register_hooks
 };
-
index 923b5f7c2cef683e9a545b56534ec3528f2d315a..7d04dd11d5d1a549c10faa1b98c942060a25f48c 100644 (file)
@@ -152,7 +152,7 @@ typedef struct {
 /* cache info information */
 typedef struct cache_info cache_info;
 struct cache_info {
-    char *content_type;
+    const char *content_type;
     const char *etag;
     const char *lastmods;      /* last modified of cache entity */
     apr_time_t date;