mod_mem_cache.c revision 2fc50921b88defeb7127985dfe4b4130175e069e
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder/* ====================================================================
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * The Apache Software License, Version 1.1
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * Redistribution and use in source and binary forms, with or without
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * modification, are permitted provided that the following conditions
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * 1. Redistributions of source code must retain the above copyright
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * notice, this list of conditions and the following disclaimer.
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * 2. Redistributions in binary form must reproduce the above copyright
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * notice, this list of conditions and the following disclaimer in
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * the documentation and/or other materials provided with the
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * distribution.
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * 3. The end-user documentation included with the redistribution,
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * if any, must include the following acknowledgment:
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * "This product includes software developed by the
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * Apache Software Foundation (http://www.apache.org/)."
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * Alternately, this acknowledgment may appear in the software itself,
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * if and wherever such third-party acknowledgments normally appear.
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * 4. The names "Apache" and "Apache Software Foundation" must
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * not be used to endorse or promote products derived from this
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * software without prior written permission. For written
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * permission, please contact apache@apache.org.
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * 5. Products derived from this software may not be called "Apache",
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * nor may "Apache" appear in their name, without prior written
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * permission of the Apache Software Foundation.
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * SUCH DAMAGE.
41582f75931338095dc749c455593c859376d593Christian Maeder * ====================================================================
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * This software consists of voluntary contributions made by many
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * individuals on behalf of the Apache Software Foundation. For more
f0cb315452faea6fee8144489629e63e9bd7b303Christian Maeder * information on the Apache Software Foundation, please see
#define CORE_PRIVATE
#define CACHE_FD 0
#include "mod_cache.h"
#include "ap_mpm.h"
#include "apr_thread_mutex.h"
#include <unistd.h>
#if !APR_HAS_THREADS
} cache_type_e;
char* hdr;
char* val;
typedef struct mem_cache_object {
#define DEFAULT_MIN_CACHE_OBJECT_SIZE 0
if (mobj) {
#ifdef WIN32
#ifdef USE_ATOMICS
return APR_SUCCESS;
if (!co) {
return APR_SUCCESS;
if (obj) {
#ifdef USE_ATOMICS
return APR_SUCCESS;
int threaded_mpm;
if (threaded_mpm) {
return sconf;
const char *type,
const char *key,
return DECLINED;
return DECLINED;
return DECLINED;
return DECLINED;
if (!obj) {
return DECLINED;
return DECLINED;
if (!mobj) {
return DECLINED;
#ifdef USE_ATOMICS
key,
if (!tmp_obj) {
if (tmp_obj) {
return DECLINED;
return OK;
return DECLINED;
if (obj) {
#ifdef USE_ATOMICS
if (!obj) {
return DECLINED;
return OK;
if (obj) {
#ifndef USE_ATOMICS
#ifdef USE_ATOMICS
return OK;
apr_ssize_t i;
char *buf;
if (*nelts == 0 ) {
return APR_SUCCESS;
return APR_ENOMEM;
if (!buf) {
return APR_ENOMEM;
for (i = 0; i < *nelts; ++i) {
return APR_SUCCESS;
int num_headers,
apr_table_t *t )
for (i = 0; i < num_headers; ++i) {
return APR_SUCCESS;
return DECLINED;
if (obj) {
#ifdef USE_ATOMICS
#ifdef USE_ATOMICS
if (obj) {
return OK;
int rc;
r->headers_out);
r->subprocess_env);
r->notes);
return rc;
apr_bucket *b;
return APR_SUCCESS;
int rc;
r->headers_out);
return rc;
r->subprocess_env );
return rc;
return rc;
return APR_ENOMEM;
return APR_ENOMEM;
return APR_SUCCESS;
apr_bucket *e;
char *cur;
if (CACHE_FD) {
int fd = 0;
int other = 0;
APR_BRIGADE_FOREACH(e, b) {
if (APR_BUCKET_IS_EOS(e)) {
else if (APR_BUCKET_IS_FILE(e)) {
fd++;
other++;
return rv;
#ifdef USE_ATOMICS
return APR_SUCCESS;
return APR_ENOMEM;
APR_BRIGADE_FOREACH(e, b) {
if (APR_BUCKET_IS_EOS(e)) {
#ifdef USE_ATOMICS
return rv;
if (len ) {
return APR_SUCCESS;
int val;
return NULL;
return NULL;
return NULL;
return NULL;
{NULL}