From c8d186a817db6c9c59cfa1a27762d67e2ec85a4e Mon Sep 17 00:00:00 2001 From: Ryan Bloom Date: Wed, 21 Nov 2001 18:25:40 +0000 Subject: [PATCH] Fix a bug in our output filter buffering. If a lot of small brigades are sent, the core will send the first 16 buckets, regardless of how much data there is. In the pathological case, this can cause a lot of 16 byte packets. Now, if we see less than AP_MIN_BYTES, we combine all of the buckets into a single bucket to be sent in a later packet. This can cause a lot of memory copies, but it eases our network traffic. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@92097 13f79535-47bb-0310-9956-ffa450edef68 --- modules/generators/config5.m4 | 1 + server/core.c | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/modules/generators/config5.m4 b/modules/generators/config5.m4 index 7113018226..84eea049f3 100644 --- a/modules/generators/config5.m4 +++ b/modules/generators/config5.m4 @@ -8,6 +8,7 @@ APACHE_MODULE(status, process/thread monitoring, , , yes) APACHE_MODULE(autoindex, directory listing, , , yes) APACHE_MODULE(asis, as-is filetypes, , , yes) APACHE_MODULE(info, server information, , , most) +APACHE_MODULE(test_pass_brigade, TEST, , , most) APACHE_MODULE(suexec, set uid and gid for spawned processes, , , no, [ other_targets=suexec ] ) diff --git a/server/core.c b/server/core.c index 779001a79a..1296fea71d 100644 --- a/server/core.c +++ b/server/core.c @@ -3079,9 +3079,26 @@ static apr_status_t core_output_filter(ap_filter_t *f, apr_bucket_brigade *b) if (n) { if (!fd) { if (nvec == MAX_IOVEC_TO_WRITE) { - /* woah! too many. stop now. */ - more = apr_brigade_split(b, e); - break; + /* woah! too many. buffer them up, for use later. */ + apr_bucket *temp; + apr_bucket_brigade *temp_brig; + + temp_brig = apr_brigade_create(f->c->pool); + temp = APR_BRIGADE_FIRST(b); + while (temp != e) { + apr_bucket *d; + rv = apr_bucket_read(e, &str, &n, APR_BLOCK_READ); + apr_brigade_write(temp_brig, NULL, NULL, str, n); + d = temp; + temp = APR_BUCKET_NEXT(temp); + apr_bucket_delete(d); + } + temp = APR_BRIGADE_FIRST(temp_brig); + APR_BUCKET_REMOVE(temp); + APR_BRIGADE_INSERT_HEAD(b, temp); + apr_brigade_destroy(temp_brig); + e = temp; + nvec = 0; } vec[nvec].iov_base = (char*) str; vec[nvec].iov_len = n; -- 2.50.1