View | Details | Raw Unified | Return to bug 39380
Collapse All | Expand All

(-)../dist/modules/cache/mod_disk_cache.c (-9 / +37 lines)
Lines 757-765 Link Here
757
    apr_bucket *e;
757
    apr_bucket *e;
758
    disk_cache_object_t *dobj = (disk_cache_object_t*) h->cache_obj->vobj;
758
    disk_cache_object_t *dobj = (disk_cache_object_t*) h->cache_obj->vobj;
759
759
760
    e = apr_bucket_file_create(dobj->fd, 0, (apr_size_t) dobj->file_size, p,
760
761
                               bb->bucket_alloc);
761
    /* For platforms where the size of the file may be larger than
762
    APR_BRIGADE_INSERT_HEAD(bb, e);
762
     * that which can be stored in a single bucket (where the
763
     * length field is an apr_size_t), split it into several
764
     * buckets: */
765
    if (sizeof(apr_off_t) > sizeof(apr_size_t)
766
            && dobj->file_size > AP_MAX_SENDFILE) {
767
        apr_off_t fsize = dobj->file_size;
768
        e = apr_bucket_file_create(dobj->fd, 0, AP_MAX_SENDFILE,
769
                p, bb->bucket_alloc);
770
        while (fsize > AP_MAX_SENDFILE) {
771
            APR_BRIGADE_INSERT_TAIL(bb, e);
772
            apr_bucket_copy(e, &e);
773
            e->start += AP_MAX_SENDFILE;
774
            fsize -= AP_MAX_SENDFILE;
775
        }
776
        e->length = (apr_size_t)fsize; /* Resize just the last bucket */
777
    }
778
    else {
779
        e = apr_bucket_file_create(dobj->fd, 0, (apr_size_t)dobj->file_size, p,
780
                bb->bucket_alloc);
781
    }
782
783
    APR_BRIGADE_INSERT_TAIL(bb, e);
763
    e = apr_bucket_eos_create(bb->bucket_alloc);
784
    e = apr_bucket_eos_create(bb->bucket_alloc);
764
    APR_BRIGADE_INSERT_TAIL(bb, e);
785
    APR_BRIGADE_INSERT_TAIL(bb, e);
765
786
Lines 1005-1012 Link Here
1005
        dobj->file_size += written;
1026
        dobj->file_size += written;
1006
        if (dobj->file_size > conf->maxfs) {
1027
        if (dobj->file_size > conf->maxfs) {
1007
            ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
1028
            ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
1008
                         "cache_disk: URL %s failed the size check "
1029
                         "disk_cache: URL %s failed the size check "
1009
                         "(%" APR_OFF_T_FMT ">%" APR_SIZE_T_FMT ")",
1030
                         "(%" APR_OFF_T_FMT ">%" APR_OFF_T_FMT ")",
1010
                         h->cache_obj->key, dobj->file_size, conf->maxfs);
1031
                         h->cache_obj->key, dobj->file_size, conf->maxfs);
1011
            /* Remove the intermediate cache file and return non-APR_SUCCESS */
1032
            /* Remove the intermediate cache file and return non-APR_SUCCESS */
1012
            file_cache_errorcleanup(dobj, r);
1033
            file_cache_errorcleanup(dobj, r);
Lines 1029-1036 Link Here
1029
        }
1050
        }
1030
        if (dobj->file_size < conf->minfs) {
1051
        if (dobj->file_size < conf->minfs) {
1031
            ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
1052
            ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
1032
                         "cache_disk: URL %s failed the size check "
1053
                         "disk_cache: URL %s failed the size check "
1033
                         "(%" APR_OFF_T_FMT "<%" APR_SIZE_T_FMT ")",
1054
                         "(%" APR_OFF_T_FMT "<%" APR_OFF_T_FMT ")",
1034
                         h->cache_obj->key, dobj->file_size, conf->minfs);
1055
                         h->cache_obj->key, dobj->file_size, conf->minfs);
1035
            /* Remove the intermediate cache file and return non-APR_SUCCESS */
1056
            /* Remove the intermediate cache file and return non-APR_SUCCESS */
1036
            file_cache_errorcleanup(dobj, r);
1057
            file_cache_errorcleanup(dobj, r);
Lines 1117-1123 Link Here
1117
{
1138
{
1118
    disk_cache_conf *conf = ap_get_module_config(parms->server->module_config,
1139
    disk_cache_conf *conf = ap_get_module_config(parms->server->module_config,
1119
                                                 &disk_cache_module);
1140
                                                 &disk_cache_module);
1120
    conf->minfs = atoi(arg);
1141
1142
    if (sscanf(arg, "%" APR_OFF_T_FMT, &conf->minfs) != 1) {
1143
        return "CacheMinFileSize argument must be an integer representing the min size of a file to cache in bytes.";
1144
    }
1121
    return NULL;
1145
    return NULL;
1122
}
1146
}
1123
static const char
1147
static const char
Lines 1125-1131 Link Here
1125
{
1149
{
1126
    disk_cache_conf *conf = ap_get_module_config(parms->server->module_config,
1150
    disk_cache_conf *conf = ap_get_module_config(parms->server->module_config,
1127
                                                 &disk_cache_module);
1151
                                                 &disk_cache_module);
1128
    conf->maxfs = atoi(arg);
1152
1153
    if (sscanf(arg, "%" APR_OFF_T_FMT, &conf->maxfs) != 1) {
1154
        return "CacheMaxFileSize argument must be an integer representing the max size of a file to cache in bytes.";
1155
    }
1156
1129
    return NULL;
1157
    return NULL;
1130
}
1158
}
1131
1159
(-)../dist/modules/cache/mod_disk_cache.h (-2 / +2 lines)
Lines 88-95 Link Here
88
    apr_size_t cache_root_len;
88
    apr_size_t cache_root_len;
89
    int dirlevels;               /* Number of levels of subdirectories */
89
    int dirlevels;               /* Number of levels of subdirectories */
90
    int dirlength;               /* Length of subdirectory names */
90
    int dirlength;               /* Length of subdirectory names */
91
    apr_size_t minfs;            /* minumum file size for cached files */
91
    apr_off_t minfs;             /* minumum file size for cached files */
92
    apr_size_t maxfs;            /* maximum file size for cached files */
92
    apr_off_t maxfs;             /* maximum file size for cached files */
93
} disk_cache_conf;
93
} disk_cache_conf;
94
94
95
#endif /*MOD_DISK_CACHE_H*/
95
#endif /*MOD_DISK_CACHE_H*/

Return to bug 39380