You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by st...@apache.org on 2002/03/07 23:13:15 UTC
cvs commit: httpd-2.0/modules/experimental cache_storage.c mod_cache.h mod_disk_cache.c mod_mem_cache.c
stoddard 02/03/07 14:13:15
Modified: modules/experimental cache_storage.c mod_cache.h
mod_disk_cache.c mod_mem_cache.c
Log:
Change the return type on read_headers, write_headers, read_body and write_body.
Sanitize some of the return codes.
Revision Changes Path
1.17 +8 -9 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.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- cache_storage.c 15 Feb 2002 03:54:47 -0000 1.16
+++ cache_storage.c 7 Mar 2002 22:13:15 -0000 1.17
@@ -219,23 +219,23 @@
request_rec *r,
cache_info *info)
{
- h->write_headers(h, r, info);
- return APR_SUCCESS;
+ return (h->write_headers(h, r, info));
}
apr_status_t cache_write_entity_body(cache_handle_t *h, request_rec *r, apr_bucket_brigade *b)
{
- apr_status_t rv = APR_SUCCESS;
- if (h->write_body(h, r, b) != OK) {
- }
- return rv;
+ return (h->write_body(h, r, b));
}
apr_status_t cache_read_entity_headers(cache_handle_t *h, request_rec *r)
{
+ apr_status_t rv;
cache_info *info = &(h->cache_obj->info);
/* Build the header table from info in the info struct */
- h->read_headers(h, r);
+ rv = h->read_headers(h, r);
+ if (rv != APR_SUCCESS) {
+ return rv;
+ }
r->content_type = apr_pstrdup(r->pool, info->content_type);
r->filename = apr_pstrdup(r->pool, info->filename );
@@ -244,8 +244,7 @@
}
apr_status_t cache_read_entity_body(cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *b)
{
- h->read_body(h, p, b);
- return APR_SUCCESS;
+ return (h->read_body(h, p, b));
}
apr_status_t cache_generate_key_default( request_rec *r, apr_pool_t*p, char**key )
1.20 +4 -4 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.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- mod_cache.h 13 Feb 2002 15:25:39 -0000 1.19
+++ mod_cache.h 7 Mar 2002 22:13:15 -0000 1.20
@@ -208,10 +208,10 @@
struct cache_handle {
cache_object_t *cache_obj;
int (*remove_entity) (cache_handle_t *h);
- int (*write_headers)(cache_handle_t *h, request_rec *r, cache_info *i);
- int (*write_body)(cache_handle_t *h, request_rec *r, apr_bucket_brigade *b);
- int (*read_headers) (cache_handle_t *h, request_rec *r);
- int (*read_body) (cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *bb);
+ apr_status_t (*write_headers)(cache_handle_t *h, request_rec *r, cache_info *i);
+ apr_status_t (*write_body)(cache_handle_t *h, request_rec *r, apr_bucket_brigade *b);
+ apr_status_t (*read_headers) (cache_handle_t *h, request_rec *r);
+ apr_status_t (*read_body) (cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *bb);
};
/* per request cache information */
1.27 +12 -13 httpd-2.0/modules/experimental/mod_disk_cache.c
Index: mod_disk_cache.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_disk_cache.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- mod_disk_cache.c 19 Feb 2002 23:20:13 -0000 1.26
+++ mod_disk_cache.c 7 Mar 2002 22:13:15 -0000 1.27
@@ -121,10 +121,10 @@
/* Forward declarations */
static int remove_entity(cache_handle_t *h);
-static int write_headers(cache_handle_t *h, request_rec *r, cache_info *i);
-static int write_body(cache_handle_t *h, request_rec *r, apr_bucket_brigade *b);
-static int read_headers(cache_handle_t *h, request_rec *r);
-static int read_body(cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *bb);
+static apr_status_t write_headers(cache_handle_t *h, request_rec *r, cache_info *i);
+static apr_status_t write_body(cache_handle_t *h, request_rec *r, apr_bucket_brigade *b);
+static apr_status_t read_headers(cache_handle_t *h, request_rec *r);
+static apr_status_t read_body(cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *bb);
/*
* Local static functions
@@ -447,7 +447,7 @@
* @@@: XXX: FIXME: currently the headers are passed thru un-merged.
* Is that okay, or should they be collapsed where possible?
*/
-static int read_headers(cache_handle_t *h, request_rec *r)
+static apr_status_t read_headers(cache_handle_t *h, request_rec *r)
{
apr_status_t rv;
char *temp;
@@ -499,7 +499,7 @@
return APR_SUCCESS;
}
-static int read_body(cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *bb)
+static apr_status_t read_body(cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *bb)
{
apr_bucket *e;
disk_cache_object_t *dobj = (disk_cache_object_t*) h->cache_obj->vobj;
@@ -510,10 +510,10 @@
e = apr_bucket_eos_create();
APR_BRIGADE_INSERT_TAIL(bb, e);
- return OK;
+ return APR_SUCCESS;
}
-static int write_headers(cache_handle_t *h, request_rec *r, cache_info *info)
+static apr_status_t write_headers(cache_handle_t *h, request_rec *r, cache_info *info)
{
disk_cache_conf *conf = ap_get_module_config(r->server->module_config,
&disk_cache_module);
@@ -549,7 +549,6 @@
APR_WRITE | APR_CREATE | APR_EXCL,
0, r->pool);
if (rv != APR_SUCCESS) {
- /* XXX */
return rv;
}
hfd = dobj->hfd;
@@ -589,9 +588,9 @@
ap_log_error(APLOG_MARK, APLOG_INFO|APLOG_NOERRNO, 0, r->server,
"disk_cache: Caching headers for URL %s", dobj->name);
- return OK;
+ return APR_SUCCESS;
}
-static int write_body(cache_handle_t *h, request_rec *r, apr_bucket_brigade *b)
+static apr_status_t write_body(cache_handle_t *h, request_rec *r, apr_bucket_brigade *b)
{
apr_bucket *e;
apr_status_t rv;
@@ -603,7 +602,7 @@
APR_WRITE | APR_CREATE | APR_BINARY| APR_TRUNCATE | APR_BUFFERED,
APR_UREAD | APR_UWRITE, r->pool);
if (rv != APR_SUCCESS) {
- return DECLINED;
+ return rv;
}
}
APR_BRIGADE_FOREACH(e, b) {
@@ -618,7 +617,7 @@
"disk_cache: Cached body for URL %s", dobj->name);
}
- return OK;
+ return APR_SUCCESS;
}
static void *create_config(apr_pool_t *p, server_rec *s)
1.26 +27 -28 httpd-2.0/modules/experimental/mod_mem_cache.c
Index: mod_mem_cache.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_mem_cache.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- mod_mem_cache.c 7 Mar 2002 21:44:49 -0000 1.25
+++ mod_mem_cache.c 7 Mar 2002 22:13:15 -0000 1.26
@@ -127,10 +127,10 @@
/* Forward declarations */
static int remove_entity(cache_handle_t *h);
-static int write_headers(cache_handle_t *h, request_rec *r, cache_info *i);
-static int write_body(cache_handle_t *h, request_rec *r, apr_bucket_brigade *b);
-static int read_headers(cache_handle_t *h, request_rec *r);
-static int read_body(cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *bb);
+static apr_status_t write_headers(cache_handle_t *h, request_rec *r, cache_info *i);
+static apr_status_t write_body(cache_handle_t *h, request_rec *r, apr_bucket_brigade *b);
+static apr_status_t read_headers(cache_handle_t *h, request_rec *r);
+static apr_status_t read_body(cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *bb);
static void cleanup_cache_object(cache_object_t *obj)
{
@@ -451,9 +451,9 @@
return OK;
}
-static int serialize_table(cache_header_tbl_t **obj,
- apr_ssize_t *nelts,
- apr_table_t *table)
+static apr_status_t serialize_table(cache_header_tbl_t **obj,
+ apr_ssize_t *nelts,
+ apr_table_t *table)
{
apr_table_entry_t *elts = (apr_table_entry_t *) table->a.elts;
apr_ssize_t i;
@@ -462,13 +462,13 @@
char *buf;
*nelts = table->a.nelts;
- if (*nelts ==0 ) {
+ if (*nelts == 0 ) {
*obj=NULL;
- return OK;
+ return APR_SUCCESS;
}
*obj = calloc(1, sizeof(cache_header_tbl_t) * table->a.nelts);
if (NULL == *obj) {
- return DECLINED;
+ return APR_ENOMEM;
}
for (i = 0; i < table->a.nelts; ++i) {
len += strlen(elts[i].key);
@@ -480,7 +480,7 @@
buf = calloc(1, len);
if (!buf) {
*obj = NULL;
- return DECLINED;
+ return APR_ENOMEM;
}
for (i = 0; i < *nelts; ++i) {
@@ -494,7 +494,7 @@
strncpy(&buf[idx], elts[i].val, len);
idx+=len;
}
- return OK;
+ return APR_SUCCESS;
}
static int unserialize_table( cache_header_tbl_t *ctbl,
int num_headers,
@@ -506,7 +506,7 @@
apr_table_setn(t, ctbl[i].hdr, ctbl[i].val);
}
- return OK;
+ return APR_SUCCESS;
}
/* Define request processing hook handlers */
static int remove_url(const char *type, const char *key)
@@ -552,7 +552,7 @@
return OK;
}
-static int read_headers(cache_handle_t *h, request_rec *r)
+static apr_status_t read_headers(cache_handle_t *h, request_rec *r)
{
int rc;
mem_cache_object_t *mobj = (mem_cache_object_t*) h->cache_obj->vobj;
@@ -570,10 +570,9 @@
mobj->num_notes,
r->notes);
return rc;
-
}
-static int read_body(cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *bb)
+static apr_status_t read_body(cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *bb)
{
apr_bucket *b;
mem_cache_object_t *mobj = (mem_cache_object_t*) h->cache_obj->vobj;
@@ -583,11 +582,11 @@
b = apr_bucket_eos_create();
APR_BRIGADE_INSERT_TAIL(bb, b);
- return OK;
+ return APR_SUCCESS;
}
-static int write_headers(cache_handle_t *h, request_rec *r, cache_info *info)
+static apr_status_t write_headers(cache_handle_t *h, request_rec *r, cache_info *info)
{
cache_object_t *obj = h->cache_obj;
mem_cache_object_t *mobj = (mem_cache_object_t*) h->cache_obj->vobj;
@@ -597,18 +596,18 @@
rc = serialize_table(&mobj->header_out,
&mobj->num_header_out,
r->headers_out);
- if (rc != OK ) {
+ if (rc != APR_SUCCESS) {
return rc;
}
rc = serialize_table(&mobj->subprocess_env,
&mobj->num_subprocess_env,
r->subprocess_env );
- if (rc != OK ) {
+ if (rc != APR_SUCCESS) {
return rc;
}
rc = serialize_table(&mobj->notes, &mobj->num_notes, r->notes);
- if (rc != OK ) {
+ if (rc != APR_SUCCESS) {
return rc;
}
@@ -625,22 +624,22 @@
if (info->content_type) {
obj->info.content_type = (char*) calloc(1, strlen(info->content_type) + 1);
if (!obj->info.content_type) {
- return DECLINED;
+ return APR_ENOMEM;
}
strcpy((char*) obj->info.content_type, info->content_type);
}
if ( info->filename) {
obj->info.filename = (char*) calloc(1, strlen(info->filename) + 1);
if (!obj->info.filename ) {
- return DECLINED;
+ return APR_ENOMEM;
}
strcpy((char*) obj->info.filename, info->filename );
}
- return OK;
+ return APR_SUCCESS;
}
-static int write_body(cache_handle_t *h, request_rec *r, apr_bucket_brigade *b)
+static apr_status_t write_body(cache_handle_t *h, request_rec *r, apr_bucket_brigade *b)
{
apr_status_t rv;
mem_cache_object_t *mobj = (mem_cache_object_t*) h->cache_obj->vobj;
@@ -655,7 +654,7 @@
if (mobj->m == NULL) {
mobj->m = malloc(mobj->m_len);
if (mobj->m == NULL) {
- return DECLINED;
+ return APR_ENOMEM;
}
mobj->type = CACHE_TYPE_HEAP;
h->cache_obj->count = 0;
@@ -678,7 +677,7 @@
}
rv = apr_bucket_read(e, &s, &len, eblock);
if (rv != APR_SUCCESS) {
- return DECLINED;
+ return rv;
}
/* XXX Check for overflow */
if (len ) {
@@ -691,7 +690,7 @@
*/
AP_DEBUG_ASSERT(h->cache_obj->count > mobj->m_len);
}
- return OK;
+ return APR_SUCCESS;
}
static const char