58module AP_MODULE_DECLARE_DATA cache_disk_module;
77 if (!
dobj->hashfile) {
95 if (!
dobj->hashfile) {
136 const char *
src,
const char *
dest,
177 "rename tempfile to file failed:"
178 " %s -> %s",
file->tempfile,
file->file);
233 info->status =
dobj->disk_info.status;
235 info->expire =
dobj->disk_info.expire;
236 info->request_time =
dobj->disk_info.request_time;
237 info->response_time =
dobj->disk_info.response_time;
244 len =
dobj->disk_info.name_len;
271 elts = (
const char **)
varray->elts;
302 iov[k].iov_base = (
char*) elts[
i];
303 iov[k].iov_len = strlen(elts[
i]);
305 iov[k].iov_base = (
char*) header;
306 iov[k].iov_len = strlen(header);
355 "URL %s partial content response not cached",
363 "URL %s failed the size check "
370 "URL %s failed the size check "
413#ifdef APR_SENDFILE_ENABLED
430 "Cannot cache files to disk without a CacheRoot specified.");
463 len =
sizeof(expire);
470 "Cannot parse vary header file: %s",
491 "File '%s' has a version mismatch. File had version: %d.",
528 "Cannot read header file %s",
dobj->hdrs.file);
537 "HEAD request cached, non-HEAD requested, ignoring: %s",
544 if (
dobj->disk_info.has_body) {
546#ifdef APR_SENDFILE_ENABLED
556 "Cannot open data file %s",
dobj->data.file);
568 if (
dobj->disk_info.inode == finfo.
inode &&
573 "Recalled cached URL info header %s",
dobj->name);
594 "Cached URL info header '%s' didn't match body, ignoring this entry",
638 if (
dobj->hdrs.file) {
640 "Deleting %s from cache.",
dobj->hdrs.file);
648 "Failed to delete headers file %s from cache.",
655 if (
dobj->data.file) {
657 "Deleting %s from cache.",
dobj->data.file);
665 "Failed to delete data file %s from cache.",
695 for (q =
dir +
dobj->root_len; *q ; ) {
697 "Deleting directory %s from cache",
dir);
723 "Premature end of vary array.");
728 if (
p > 0 && w[
p - 1] ==
'\n') {
729 if (
p > 1 && w[
p - 2] ==
CR) {
756 elts = (
const char **)
arr->
elts;
759 iov[0].iov_base = (
char*) elts[
i];
760 iov[0].iov_len = strlen(elts[
i]);
762 iov[1].iov_len =
sizeof(
CRLF) - 1;
771 iov[0].iov_len =
sizeof(
CRLF) - 1;
790 "Premature end of cache headers.");
801 if (
p > 0 && w[
p - 1] ==
'\n') {
802 if (
p > 1 && w[
p - 2] ==
CR) {
815#if APR_CHARSET_EBCDIC
819 if (!(l =
strchr(w,
':'))) {
821 unsigned char *cp,
native;
824 for (cp = w; *cp !=
'\0'; ++cp) {
833 "CGI Interface Error: Script headers apparently ASCII: (CGI = %s)",
843 if (!(l =
strchr(w,
':'))) {
871 if (!
dobj->hdrs.fd) {
873 "recalling headers; but no header fd for %s",
dobj->name);
884 "Error reading response headers from %s for %s",
890 "Error reading request headers from %s for %s",
897 "Recalled headers for URL %s",
dobj->name);
924 iov[0].iov_len = strlen(elts[
i].
key);
925 iov[1].iov_base =
": ";
926 iov[1].iov_len =
sizeof(
": ") - 1;
928 iov[2].iov_len = strlen(elts[
i].
val);
930 iov[3].iov_len =
sizeof(
CRLF) - 1;
939 iov[0].iov_len =
sizeof(
CRLF) - 1;
959 dobj->disk_info.header_only = 1;
978 if (
dobj->headers_out) {
1005 "could not create vary file %s",
1006 dobj->vary.tempfile);
1014 "could not write to vary file %s",
1015 dobj->vary.tempfile);
1021 amt =
sizeof(
h->cache_obj->info.expire);
1023 &
h->cache_obj->info.expire,
amt,
NULL);
1026 "could not write to vary file %s",
1027 dobj->vary.tempfile);
1041 "could not close vary file %s",
1042 dobj->vary.tempfile);
1062 "could not create header file %s",
1063 dobj->hdrs.tempfile);
1068 disk_info.
date =
h->cache_obj->info.date;
1069 disk_info.
expire =
h->cache_obj->info.expire;
1073 disk_info.
status =
h->cache_obj->info.status;
1074 disk_info.
inode =
dobj->disk_info.inode;
1083 iov[0].iov_base = (
void*)&disk_info;
1085 iov[1].iov_base = (
void*)
dobj->name;
1092 "could not write info to header file %s",
1093 dobj->hdrs.tempfile);
1099 if (
dobj->headers_out) {
1103 "could not write out-headers to header file %s",
1104 dobj->hdrs.tempfile);
1113 if (
dobj->headers_in) {
1117 "could not write in-headers to header file %s",
1118 dobj->hdrs.tempfile);
1128 "could not close header file %s",
1129 dobj->hdrs.tempfile);
1146 if (!
dobj->offset) {
1164 if (
dobj->done || !
dobj->data.pool) {
1199 "Error when reading bucket for URL %s",
1211 if (!
dobj->disk_info.header_only) {
1216 if (!
dobj->data.tempfd) {
1225 dobj->file_size = 0;
1234 dobj->disk_info.has_body = 1;
1246 dobj->file_size += written;
1264 if (
dobj->offset <= 0) {
1279 if (!
dobj->disk_info.header_only) {
1283 if (
dobj->data.tempfd) {
1295 "because connection has been aborted.",
h->cache_obj->key);
1312 ||
cl !=
dobj->file_size)) {
1330 &cache_disk_module);
1345 if (!
dobj->disk_info.header_only) {
1348 else if (
dobj->data.file) {
1357 "commit_entity: URL '%s' not cached due to earlier disk error.",
1362 "commit_entity: Headers and body for URL %s cached.",
1381 h->cache_obj->info.control.invalidated = 1;
1437 &cache_disk_module);
1455 &cache_disk_module);
1458 return "CacheDirLevels value must be an integer greater than 0";
1460 return "CacheDirLevels*CacheDirLength value must not be higher than 20";
1468 &cache_disk_module);
1471 return "CacheDirLength value must be an integer greater than 0";
1473 return "CacheDirLevels*CacheDirLength value must not be higher than 20";
1487 return "CacheMinFileSize argument must be a non-negative integer representing the min size of a file to cache in bytes.";
1501 return "CacheMaxFileSize argument must be a non-negative integer representing the max size of a file to cache in bytes.";
1515 return "CacheReadSize argument must be a non-negative integer representing the max amount of data to cache in go.";
1530 return "CacheReadTime argument must be a non-negative integer representing the max amount of time taken to cache in go.";
1540 "The directory to store cache files"),
1542 "The number of levels of subdirectories in the cache"),
1544 "The number of characters in subdirectory names"),
1546 "The minimum file size to cache a document"),
1548 "The maximum file size to cache a document"),
1550 "The maximum quantity of data to attempt to read and cache in one go"),
1552 "The maximum time taken to attempt to read and cache in go"),
const char apr_size_t len
APR general purpose library routines.
#define AP_INIT_TAKE1(directive, func, mconfig, where, help)
#define ap_get_module_config(v, m)
#define AP_DECLARE_MODULE(foo)
#define AP_SENDFILE_ENABLED(x)
#define ap_get_core_module_config(v)
apr_status_t ap_register_provider(apr_pool_t *pool, const char *provider_group, const char *provider_name, const char *provider_version, const void *provider)
#define APR_STATUS_IS_EEXIST(s)
#define APR_STATUS_IS_ENOENT(s)
#define APR_BUCKET_IS_FLUSH(e)
#define APR_BUCKET_REMOVE(e)
#define APR_BUCKET_IS_METADATA(e)
#define APR_BRIGADE_INSERT_TAIL(b, e)
#define APR_BRIGADE_EMPTY(b)
#define APR_BUCKET_IS_EOS(e)
#define APR_BRIGADE_FIRST(b)
#define apr_bucket_read(e, str, len, block)
apr_pool_t const char apr_dbd_t ** handle
const char apr_ssize_t int flags
const char apr_size_t * inbytes_left
const char apr_size_t char apr_size_t * outbytes_left
#define VARY_FORMAT_VERSION
#define CACHE_HEADER_SUFFIX
#define CACHE_DATA_SUFFIX
#define DISK_FORMAT_VERSION
#define CACHE_VDIR_SUFFIX
#define HTTP_NOT_MODIFIED
#define HTTP_PARTIAL_CONTENT
#define CACHE_PROVIDER_GROUP
char * ap_cache_generate_name(apr_pool_t *p, int dirlevels, int dirlength, const char *name)
apr_table_t * ap_cache_cacheable_headers_in(request_rec *r)
apr_table_t * ap_cache_cacheable_headers_out(request_rec *r)
#define STANDARD20_MODULE_STUFF
char * ap_get_list_item(apr_pool_t *p, const char **field)
int ap_parse_strict_length(apr_off_t *len, const char *str)
const char int apr_pool_t * pool
apr_seek_where_t apr_off_t * offset
const char apr_file_t * file
const struct iovec apr_size_t nvec
#define apr_pool_create(newpool, parent)
#define apr_pcalloc(p, size)
const apr_array_header_t * arr
#define apr_time_from_msec(msec)
Main include file for the Apache Transparent Cache.
static const char * set_cache_dirlength(cmd_parms *parms, void *in_struct_ptr, const char *arg)
static const command_rec disk_cache_cmds[]
static apr_status_t recall_body(cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *bb)
static int remove_entity(cache_handle_t *h)
static apr_status_t store_body(cache_handle_t *h, request_rec *r, apr_bucket_brigade *in, apr_bucket_brigade *out)
static apr_status_t safe_file_rename(disk_cache_conf *conf, const char *src, const char *dest, apr_pool_t *pool)
static apr_status_t commit_entity(cache_handle_t *h, request_rec *r)
static apr_status_t store_array(apr_file_t *fd, apr_array_header_t *arr)
static apr_status_t file_cache_el_final(disk_cache_conf *conf, disk_cache_file_t *file, request_rec *r)
static apr_status_t write_headers(cache_handle_t *h, request_rec *r)
static apr_status_t store_headers(cache_handle_t *h, request_rec *r, cache_info *i)
static void * create_dir_config(apr_pool_t *p, char *dummy)
static int create_entity(cache_handle_t *h, request_rec *r, const char *key, apr_off_t len, apr_bucket_brigade *bb)
static apr_status_t store_table(apr_file_t *fd, apr_table_t *table)
static const char * regen_key(apr_pool_t *p, apr_table_t *headers, apr_array_header_t *varray, const char *oldkey)
static void disk_cache_register_hook(apr_pool_t *p)
static int array_alphasort(const void *fn1, const void *fn2)
static const char * set_cache_readsize(cmd_parms *parms, void *in_struct_ptr, const char *arg)
static void * merge_dir_config(apr_pool_t *p, void *basev, void *addv)
static apr_status_t invalidate_entity(cache_handle_t *h, request_rec *r)
static const char * set_cache_root(cmd_parms *parms, void *in_struct_ptr, const char *arg)
static const char * set_cache_maxfs(cmd_parms *parms, void *in_struct_ptr, const char *arg)
static void tokens_to_array(apr_pool_t *p, const char *data, apr_array_header_t *arr)
static void * create_config(apr_pool_t *p, server_rec *s)
static const cache_provider cache_disk_provider
static apr_status_t file_cache_create(disk_cache_conf *conf, disk_cache_file_t *file, apr_pool_t *pool)
static const char * set_cache_dirlevels(cmd_parms *parms, void *in_struct_ptr, const char *arg)
static apr_status_t read_array(request_rec *r, apr_array_header_t *arr, apr_file_t *file)
static int open_entity(cache_handle_t *h, request_rec *r, const char *key)
static apr_status_t read_table(cache_handle_t *handle, request_rec *r, apr_table_t *table, apr_file_t *file)
static char * data_file(apr_pool_t *p, disk_cache_conf *conf, disk_cache_object_t *dobj, const char *name)
static apr_status_t recall_headers(cache_handle_t *h, request_rec *r)
static int file_cache_recall_mydata(apr_file_t *fd, cache_info *info, disk_cache_object_t *dobj, request_rec *r)
static apr_status_t mkdir_structure(disk_cache_conf *conf, const char *file, apr_pool_t *pool)
static void close_disk_cache_fd(disk_cache_file_t *file)
static const char * set_cache_minfs(cmd_parms *parms, void *in_struct_ptr, const char *arg)
static char * header_file(apr_pool_t *p, disk_cache_conf *conf, disk_cache_object_t *dobj, const char *name)
static const char * set_cache_readtime(cmd_parms *parms, void *in_struct_ptr, const char *arg)
static apr_status_t file_cache_temp_cleanup(void *dummy)
static int remove_url(cache_handle_t *h, request_rec *r)
#define DEFAULT_MAX_FILE_SIZE
#define DEFAULT_MIN_FILE_SIZE
#define DEFAULT_DIRLEVELS
#define DEFAULT_DIRLENGTH
Per-directory configuration.
apr_size_t cache_root_len
unsigned int readtime_set
unsigned int readsize_set
apr_size_t entity_version
A structure that represents the current request.
struct ap_conf_vector_t * per_dir_config
apr_table_t * headers_out
A structure to store information for each virtual server.
struct ap_conf_vector_t * module_config
apr_status_t apr_dir_make(const char *path, apr_fileperms_t perm, apr_pool_t *pool)
apr_status_t apr_dir_remove(const char *path, apr_pool_t *pool)