From 4fea103d289e3074644345cb0b6a7405815ee23f Mon Sep 17 00:00:00 2001 From: "William A. Rowe Jr" Date: Wed, 10 Oct 2001 20:02:40 +0000 Subject: [PATCH] Support huge files from mod_asis git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@91406 13f79535-47bb-0310-9956-ffa450edef68 --- modules/generators/mod_asis.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/modules/generators/mod_asis.c b/modules/generators/mod_asis.c index 5f6ebbdd3d..1a2430498a 100644 --- a/modules/generators/mod_asis.c +++ b/modules/generators/mod_asis.c @@ -131,6 +131,24 @@ static int asis_handler(request_rec *r) } bb = apr_brigade_create(r->pool); +#if APR_HAS_LARGE_FILES + if (r->finfo.size - pos > 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. + */ + apr_off_t fsize = r->finfo.size - pos; + e = apr_bucket_file_create(fd, pos, 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 b = apr_bucket_file_create(f, pos, (apr_size_t) (r->finfo.size - pos), r->pool); APR_BRIGADE_INSERT_TAIL(bb, b); b = apr_bucket_eos_create(); -- 2.50.1