Commit 777fc211 authored by William A. Rowe Jr's avatar William A. Rowe Jr
Browse files

  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
parent ebd177c4
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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.
+17 −7
Original line number Diff line number Diff line
@@ -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!)
    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, 0, r->finfo.size, r->pool);

    APR_BRIGADE_INSERT_HEAD(bb, e);
        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);