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

(-)../p2-checkbefore/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 980-986 Link Here
980
    if (len > conf->maxfs) {
1001
    if (len > conf->maxfs) {
981
        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
1002
        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
982
                     "disk_cache: URL %s failed the size check "
1003
                     "disk_cache: URL %s failed the size check "
983
                     "(%" APR_OFF_T_FMT ">%" APR_SIZE_T_FMT ")",
1004
                     "(%" APR_OFF_T_FMT ">%" APR_OFF_T_FMT ")",
984
                     h->cache_obj->key, len, conf->maxfs);
1005
                     h->cache_obj->key, len, conf->maxfs);
985
        /* Remove the intermediate cache file and return non-APR_SUCCESS */
1006
        /* Remove the intermediate cache file and return non-APR_SUCCESS */
986
        file_cache_errorcleanup(dobj, r);
1007
        file_cache_errorcleanup(dobj, r);
Lines 989-995 Link Here
989
    if (len >= 0 && len < conf->minfs) {
1010
    if (len >= 0 && len < conf->minfs) {
990
        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
1011
        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
991
                     "disk_cache: URL %s failed the size check "
1012
                     "disk_cache: URL %s failed the size check "
992
                     "(%" APR_OFF_T_FMT "<%" APR_SIZE_T_FMT ")",
1013
                     "(%" APR_OFF_T_FMT "<%" APR_OFF_T_FMT ")",
993
                     h->cache_obj->key, len, conf->minfs);
1014
                     h->cache_obj->key, len, conf->minfs);
994
        /* Remove the intermediate cache file and return non-APR_SUCCESS */
1015
        /* Remove the intermediate cache file and return non-APR_SUCCESS */
995
        file_cache_errorcleanup(dobj, r);
1016
        file_cache_errorcleanup(dobj, r);
Lines 1037-1043 Link Here
1037
        if (dobj->file_size > conf->maxfs) {
1058
        if (dobj->file_size > conf->maxfs) {
1038
            ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
1059
            ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
1039
                         "disk_cache: URL %s failed the size check "
1060
                         "disk_cache: URL %s failed the size check "
1040
                         "(%" APR_OFF_T_FMT ">%" APR_SIZE_T_FMT ")",
1061
                         "(%" APR_OFF_T_FMT ">%" APR_OFF_T_FMT ")",
1041
                         h->cache_obj->key, dobj->file_size, conf->maxfs);
1062
                         h->cache_obj->key, dobj->file_size, conf->maxfs);
1042
            /* Remove the intermediate cache file and return non-APR_SUCCESS */
1063
            /* Remove the intermediate cache file and return non-APR_SUCCESS */
1043
            file_cache_errorcleanup(dobj, r);
1064
            file_cache_errorcleanup(dobj, r);
Lines 1061-1067 Link Here
1061
        if (dobj->file_size < conf->minfs) {
1082
        if (dobj->file_size < conf->minfs) {
1062
            ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
1083
            ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
1063
                         "disk_cache: URL %s failed the size check "
1084
                         "disk_cache: URL %s failed the size check "
1064
                         "(%" APR_OFF_T_FMT "<%" APR_SIZE_T_FMT ")",
1085
                         "(%" APR_OFF_T_FMT "<%" APR_OFF_T_FMT ")",
1065
                         h->cache_obj->key, dobj->file_size, conf->minfs);
1086
                         h->cache_obj->key, dobj->file_size, conf->minfs);
1066
            /* Remove the intermediate cache file and return non-APR_SUCCESS */
1087
            /* Remove the intermediate cache file and return non-APR_SUCCESS */
1067
            file_cache_errorcleanup(dobj, r);
1088
            file_cache_errorcleanup(dobj, r);
Lines 1148-1154 Link Here
1148
{
1169
{
1149
    disk_cache_conf *conf = ap_get_module_config(parms->server->module_config,
1170
    disk_cache_conf *conf = ap_get_module_config(parms->server->module_config,
1150
                                                 &disk_cache_module);
1171
                                                 &disk_cache_module);
1151
    conf->minfs = atoi(arg);
1172
1173
    if (sscanf(arg, "%" APR_OFF_T_FMT, &conf->minfs) != 1) {
1174
        return "CacheMinFileSize argument must be an integer representing the min size of a file to cache in bytes.";
1175
    }
1152
    return NULL;
1176
    return NULL;
1153
}
1177
}
1154
static const char
1178
static const char
Lines 1156-1162 Link Here
1156
{
1180
{
1157
    disk_cache_conf *conf = ap_get_module_config(parms->server->module_config,
1181
    disk_cache_conf *conf = ap_get_module_config(parms->server->module_config,
1158
                                                 &disk_cache_module);
1182
                                                 &disk_cache_module);
1159
    conf->maxfs = atoi(arg);
1183
1184
    if (sscanf(arg, "%" APR_OFF_T_FMT, &conf->maxfs) != 1) {
1185
        return "CacheMaxFileSize argument must be an integer representing the max size of a file to cache in bytes.";
1186
    }
1187
1160
    return NULL;
1188
    return NULL;
1161
}
1189
}
1162
1190
(-)../p2-checkbefore/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