summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorRuediger Pluem <rpluem@apache.org>2008-10-27 12:39:04 +0100
committerRuediger Pluem <rpluem@apache.org>2008-10-27 12:39:04 +0100
commit80ddb8dadc44a38d5ca340ae414630b1b220eafc (patch)
treed5c7c442c1c1f8160698e8ac7187a47d2a76bb0b /server
parent* modules/cache/mod_socache_dbm.c (diff)
downloadapache2-80ddb8dadc44a38d5ca340ae414630b1b220eafc.tar.xz
apache2-80ddb8dadc44a38d5ca340ae414630b1b220eafc.zip
* Do more greedy reads in the core input filter to get more closer to the
number of bytes requested. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@708144 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'server')
-rw-r--r--server/core_filters.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/server/core_filters.c b/server/core_filters.c
index 4bfd41c5a8..9a07252e05 100644
--- a/server/core_filters.c
+++ b/server/core_filters.c
@@ -267,6 +267,37 @@ int ap_core_input_filter(ap_filter_t *f, apr_bucket_brigade *b,
return APR_SUCCESS;
}
+ /* Have we read as much data as we wanted (be greedy)? */
+ if (len < readbytes) {
+ apr_size_t bucket_len;
+
+ rv = APR_SUCCESS;
+ /* We already registered the data in e in len */
+ e = APR_BUCKET_NEXT(e);
+ while ((len < readbytes) && (rv == APR_SUCCESS)
+ && (e != APR_BRIGADE_SENTINEL(ctx->b))) {
+ /* Check for the availability of buckets with known length */
+ if (e->length != -1) {
+ len += e->length;
+ e = APR_BUCKET_NEXT(e);
+ }
+ else {
+ /*
+ * Read from bucket, but non blocking. If there isn't any
+ * more data, well than this is fine as well, we will
+ * not wait for more since we already got some and we are
+ * only checking if there isn't more.
+ */
+ rv = apr_bucket_read(e, &str, &bucket_len,
+ APR_NONBLOCK_READ);
+ if (rv == APR_SUCCESS) {
+ len += bucket_len;
+ e = APR_BUCKET_NEXT(e);
+ }
+ }
+ }
+ }
+
/* We can only return at most what we read. */
if (len < readbytes) {
readbytes = len;