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 );
}
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 )
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 */
/* 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
* @@@: 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;
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;
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);
APR_WRITE | APR_CREATE | APR_EXCL,
0, r->pool);
if (rv != APR_SUCCESS) {
- /* XXX */
return rv;
}
hfd = dobj->hfd;
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;
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) {
"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)
/* 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)
{
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;
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);
buf = calloc(1, len);
if (!buf) {
*obj = NULL;
- return DECLINED;
+ return APR_ENOMEM;
}
for (i = 0; i < *nelts; ++i) {
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,
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)
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;
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;
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;
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;
}
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;
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;
}
rv = apr_bucket_read(e, &s, &len, eblock);
if (rv != APR_SUCCESS) {
- return DECLINED;
+ return rv;
}
/* XXX Check for overflow */
if (len ) {
*/
AP_DEBUG_ASSERT(h->cache_obj->count > mobj->m_len);
}
- return OK;
+ return APR_SUCCESS;
}
static const char