From 154bfafb721cb8dcd28ab8987f98c6e7ee369701 Mon Sep 17 00:00:00 2001 From: Tony Finch Date: Thu, 14 Sep 2000 02:16:07 +0000 Subject: [PATCH] Improve the way the chunking filter handles zero-length buckets, and fix the comment explaining how to reduce the incidence of tiny chunks. Submitted by: Jeff Trawick Reviewed by: Tony Finch git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86222 13f79535-47bb-0310-9956-ffa450edef68 --- modules/http/http_core.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/modules/http/http_core.c b/modules/http/http_core.c index b533a80f98..61279f2fd5 100644 --- a/modules/http/http_core.c +++ b/modules/http/http_core.c @@ -2951,25 +2951,31 @@ static apr_status_t chunk_filter(ap_filter_t *f, ap_bucket_brigade *b) break; } else if (e->length == -1) { - /* Bucket Of Interdeterminate Length (BOIL). (e.g. a pipe) */ - + /* unknown amount of data (e.g. a pipe) */ const char *data; apr_ssize_t len; - /* this will construct a new bucket */ rv = e->read(e, &data, &len, 1); if (rv != APR_SUCCESS) { return rv; } - bytes += len; - - /* - * We split between the new bucket and the BOIL. We'll come - * back for the rest of the brigade later (reading more out - * of the BOIL, possibly splitting again - */ - more = ap_brigade_split(b, AP_BUCKET_NEXT(e)); - break; + if (len > 0) { + /* + * There may be a new next bucket representing the + * rest of the data stream on which a read() may + * block so we pass down what we have so far. + */ + bytes += len; + more = ap_brigade_split(b, AP_BUCKET_NEXT(e)); + break; + } + else { + /* If there was nothing in this bucket then we can + * safely move on to the next one without pausing + * to pass down what we have counted up so far. + */ + continue; + } } else { bytes += e->length; @@ -2978,7 +2984,8 @@ static apr_status_t chunk_filter(ap_filter_t *f, ap_bucket_brigade *b) /* * XXX: if there aren't very many bytes at this point it may - * be a good idea to set them aside and return for more. + * be a good idea to set them aside and return for more, + * unless we haven't finished counting this brigade yet. */ /* if there are content bytes, then wrap them in a chunk */ -- 2.40.0