--- ../p2-checkbefore/modules/cache/mod_disk_cache.c 2006-04-23 10:24:12.000000000 +0200 +++ ../p2-checkbefore/modules/cache/mod_disk_cache.c 2006-04-23 10:29:09.000000000 +0200 @@ -757,9 +757,30 @@ apr_bucket *e; disk_cache_object_t *dobj = (disk_cache_object_t*) h->cache_obj->vobj; - e = apr_bucket_file_create(dobj->fd, 0, (apr_size_t) dobj->file_size, p, - bb->bucket_alloc); - APR_BRIGADE_INSERT_HEAD(bb, e); + + /* For platforms where the size of the file may be larger than + * that which can be stored in a single bucket (where the + * length field is an apr_size_t), split it into several + * buckets: */ + if (sizeof(apr_off_t) > sizeof(apr_size_t) + && dobj->file_size > AP_MAX_SENDFILE) { + apr_off_t fsize = dobj->file_size; + e = apr_bucket_file_create(dobj->fd, 0, AP_MAX_SENDFILE, + p, bb->bucket_alloc); + while (fsize > AP_MAX_SENDFILE) { + APR_BRIGADE_INSERT_TAIL(bb, e); + apr_bucket_copy(e, &e); + e->start += AP_MAX_SENDFILE; + fsize -= AP_MAX_SENDFILE; + } + e->length = (apr_size_t)fsize; /* Resize just the last bucket */ + } + else { + e = apr_bucket_file_create(dobj->fd, 0, (apr_size_t)dobj->file_size, p, + bb->bucket_alloc); + } + + APR_BRIGADE_INSERT_TAIL(bb, e); e = apr_bucket_eos_create(bb->bucket_alloc); APR_BRIGADE_INSERT_TAIL(bb, e); @@ -980,7 +1001,7 @@ if (len > conf->maxfs) { ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "disk_cache: URL %s failed the size check " - "(%" APR_OFF_T_FMT ">%" APR_SIZE_T_FMT ")", + "(%" APR_OFF_T_FMT ">%" APR_OFF_T_FMT ")", h->cache_obj->key, len, conf->maxfs); /* Remove the intermediate cache file and return non-APR_SUCCESS */ file_cache_errorcleanup(dobj, r); @@ -989,7 +1010,7 @@ if (len >= 0 && len < conf->minfs) { ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "disk_cache: URL %s failed the size check " - "(%" APR_OFF_T_FMT "<%" APR_SIZE_T_FMT ")", + "(%" APR_OFF_T_FMT "<%" APR_OFF_T_FMT ")", h->cache_obj->key, len, conf->minfs); /* Remove the intermediate cache file and return non-APR_SUCCESS */ file_cache_errorcleanup(dobj, r); @@ -1037,7 +1058,7 @@ if (dobj->file_size > conf->maxfs) { ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "disk_cache: URL %s failed the size check " - "(%" APR_OFF_T_FMT ">%" APR_SIZE_T_FMT ")", + "(%" APR_OFF_T_FMT ">%" APR_OFF_T_FMT ")", h->cache_obj->key, dobj->file_size, conf->maxfs); /* Remove the intermediate cache file and return non-APR_SUCCESS */ file_cache_errorcleanup(dobj, r); @@ -1061,7 +1082,7 @@ if (dobj->file_size < conf->minfs) { ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "disk_cache: URL %s failed the size check " - "(%" APR_OFF_T_FMT "<%" APR_SIZE_T_FMT ")", + "(%" APR_OFF_T_FMT "<%" APR_OFF_T_FMT ")", h->cache_obj->key, dobj->file_size, conf->minfs); /* Remove the intermediate cache file and return non-APR_SUCCESS */ file_cache_errorcleanup(dobj, r); @@ -1148,7 +1169,10 @@ { disk_cache_conf *conf = ap_get_module_config(parms->server->module_config, &disk_cache_module); - conf->minfs = atoi(arg); + + if (sscanf(arg, "%" APR_OFF_T_FMT, &conf->minfs) != 1) { + return "CacheMinFileSize argument must be an integer representing the min size of a file to cache in bytes."; + } return NULL; } static const char @@ -1156,7 +1180,11 @@ { disk_cache_conf *conf = ap_get_module_config(parms->server->module_config, &disk_cache_module); - conf->maxfs = atoi(arg); + + if (sscanf(arg, "%" APR_OFF_T_FMT, &conf->maxfs) != 1) { + return "CacheMaxFileSize argument must be an integer representing the max size of a file to cache in bytes."; + } + return NULL; } --- ../p2-checkbefore/modules/cache/mod_disk_cache.h 2006-04-23 10:15:35.000000000 +0200 +++ ../p2-checkbefore/modules/cache/mod_disk_cache.h 2006-04-23 10:27:12.000000000 +0200 @@ -88,8 +88,8 @@ apr_size_t cache_root_len; int dirlevels; /* Number of levels of subdirectories */ int dirlength; /* Length of subdirectory names */ - apr_size_t minfs; /* minumum file size for cached files */ - apr_size_t maxfs; /* maximum file size for cached files */ + apr_off_t minfs; /* minumum file size for cached files */ + apr_off_t maxfs; /* maximum file size for cached files */ } disk_cache_conf; #endif /*MOD_DISK_CACHE_H*/