From: William A. Rowe Jr Date: Wed, 25 Jul 2001 21:41:44 +0000 (+0000) Subject: This same patch is needed in mod_asis and others, I'm testing the waters X-Git-Tag: 2.0.22~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c9148bcd492decd092eeee697b60f437b727d76a;p=thirdparty%2Fapache%2Fhttpd.git This same patch is needed in mod_asis and others, I'm testing the waters for this solution. I'm easily convinced to choose AP_MAX_SENDFILE based on any reasonable argument, provided it's smaller than 2^30 :-) git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@89714 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/include/httpd.h b/include/httpd.h index 0bb3e32e58b..f18f6856e70 100644 --- a/include/httpd.h +++ b/include/httpd.h @@ -303,6 +303,14 @@ extern "C" { /* The size of the server's internal read-write buffers */ #define AP_IOBUFSIZE 8192 +/* APR_HAS_LARGE_FILES introduces the problem of spliting sendfile 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. + * ### 4mb is an invention, no idea if it is reasonable. + */ +#define AP_MAX_SENDFILE 4194304 + + /* * Special Apache error codes. These are basically used * in http_main.c so we can keep track of various errors. diff --git a/server/core.c b/server/core.c index 557c800f6ca..8749ee64ab8 100644 --- a/server/core.c +++ b/server/core.c @@ -2918,6 +2918,7 @@ static int default_handler(request_rec *r) { apr_bucket_brigade *bb; apr_bucket *e; + apr_off_t fsize, start; core_dir_config *d; int errstatus; apr_file_t *fd = NULL; @@ -2996,13 +2997,22 @@ static int default_handler(request_rec *r) } bb = apr_brigade_create(r->pool); - /* XXX: APR_HAS_LARGE_FILES issue; need to split into mutiple buckets, - * no greater than MAX(apr_size_t), (perhaps more granular than that - * in case the brigade code/filters attempt to read it!) - */ - e = apr_bucket_file_create(fd, 0, r->finfo.size, r->pool); - - APR_BRIGADE_INSERT_HEAD(bb, e); + fsize = r->finfo.size; + start = 0; +#ifdef APR_HAS_LARGE_FILES + while (fsize > 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; + } +#endif + e = apr_bucket_file_create(fd, start, (apr_size_t)fsize, r->pool); + APR_BRIGADE_INSERT_TAIL(bb, e); e = apr_bucket_eos_create(); APR_BRIGADE_INSERT_TAIL(bb, e);