You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by tr...@apache.org on 2001/08/23 21:46:55 UTC
cvs commit: httpd-2.0/modules/experimental cache_storage.c mod_cache.c mod_cache.h
trawick 01/08/23 12:46:55
Modified: modules/experimental cache_storage.c mod_cache.c mod_cache.h
Log:
mod_cache cleanup:
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
Revision Changes Path
1.2 +5 -4 httpd-2.0/modules/experimental/cache_storage.c
Index: cache_storage.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/experimental/cache_storage.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- cache_storage.c 2001/08/23 14:15:00 1.1
+++ cache_storage.c 2001/08/23 19:46:55 1.2
@@ -66,7 +66,7 @@
APR_HOOK_LINK(open_entity)
)
-module AP_MODULE_DECLARE_DATA tcache_module;
+module AP_MODULE_DECLARE_DATA cache_module;
/* -------------------------------------------------------------- */
@@ -105,7 +105,7 @@
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 @@
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 @@
*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) {
1.9 +24 -24 httpd-2.0/modules/experimental/mod_cache.c
Index: mod_cache.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_cache.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- mod_cache.c 2001/08/23 18:27:21 1.8
+++ mod_cache.c 2001/08/23 19:46:55 1.9
@@ -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 @@
{
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 @@
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 @@
"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)
{
- 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)
{
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 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
*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
*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
*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
*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
*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
*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 @@
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 @@
cache_cmds, /* command apr_table_t */
register_hooks
};
-
1.6 +1 -1 httpd-2.0/modules/experimental/mod_cache.h
Index: mod_cache.h
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_cache.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- mod_cache.h 2001/08/23 14:15:00 1.5
+++ mod_cache.h 2001/08/23 19:46:55 1.6
@@ -152,7 +152,7 @@
/* 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;