if (!r->header_only) {
apr_off_t start = 0;
apr_off_t fsize = r->finfo.size;
-#ifdef APR_HAS_LARGE_FILES
+#if APR_HAS_LARGE_FILES
/* must split into mutiple send_fd chunks */
while (fsize > AP_MAX_SENDFILE) {
ap_send_fd(f, r, start, AP_MAX_SENDFILE, &nbytes);
{
apr_bucket_brigade *bb;
apr_bucket *e;
- apr_off_t fsize, start;
core_dir_config *d;
int errstatus;
apr_file_t *fd = NULL;
}
bb = apr_brigade_create(r->pool);
- fsize = r->finfo.size;
- start = 0;
-#ifdef APR_HAS_LARGE_FILES
- while (fsize > AP_MAX_SENDFILE) {
+#if APR_HAS_LARGE_FILES
+ if (r->finfo.size > AP_MAX_SENDFILE) {
/* APR_HAS_LARGE_FILES issue; must split into mutiple buckets,
* no greater than MAX(apr_size_t), and more granular than that
* in case the brigade code/filters attempt to read it directly.
*/
- e = apr_bucket_file_create(fd, start, AP_MAX_SENDFILE, r->pool);
- APR_BRIGADE_INSERT_TAIL(bb, e);
- fsize -= AP_MAX_SENDFILE;
- start += AP_MAX_SENDFILE;
+ apr_off_t fsize = r->finfo.size;
+ e = apr_bucket_file_create(fd, 0, AP_MAX_SENDFILE, r->pool);
+ 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
#endif
- e = apr_bucket_file_create(fd, start, (apr_size_t)fsize, r->pool);
+ e = apr_bucket_file_create(fd, 0, (apr_size_t)r->finfo.size, r->pool);
+
APR_BRIGADE_INSERT_TAIL(bb, e);
e = apr_bucket_eos_create();
APR_BRIGADE_INSERT_TAIL(bb, e);