]> granicus.if.org Git - apache/commitdiff
This same patch is needed in mod_asis and others, I'm testing the waters
authorWilliam A. Rowe Jr <wrowe@apache.org>
Wed, 25 Jul 2001 21:41:44 +0000 (21:41 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Wed, 25 Jul 2001 21:41:44 +0000 (21:41 +0000)
  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

include/httpd.h
server/core.c

index 0bb3e32e58b1a4cd6428b7a2c29b3f6123177e4f..f18f6856e70b754c7f2fcb78993cd33d1a0a6f02 100644 (file)
@@ -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.
index 557c800f6cafbe7b88ff8c19a2cfd01651d03b9c..8749ee64ab802d8f2c872e2b059c4727574f25bd 100644 (file)
@@ -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);