From: Ruediger Pluem Date: Mon, 14 Sep 2009 19:46:36 +0000 (+0000) Subject: * Lower memory usage by reusing the brigade instead of constantly X-Git-Tag: 2.3.3~302 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7f346368c7c3eeaf295c1194dbc0b7ab7be1c1c8;p=thirdparty%2Fapache%2Fhttpd.git * Lower memory usage by reusing the brigade instead of constantly recerating one. Submitted by: Stefan Fritsch Reviewed by: rpluem git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@814807 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 3762ea7d134..854d4af3238 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ Changes with Apache 2.3.3 + *) core: Lower memory usage of core output filter. + [Stefan Fritsch ] + *) mod_mime: Detect invalid use of MultiviewsMatch inside Location and LocationMatch sections. PR47754. [Dan Poirier] diff --git a/include/ap_mmn.h b/include/ap_mmn.h index e23b71a4a73..5a655e460da 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -194,6 +194,8 @@ * ap_my_generation, etc. ap_mpm_query() can't be called * until after the register-hooks phase. * 20090401.1 (2.3.3-dev) Protected log.c internals, http_log.h changes + * 20090401.2 (2.3.3-dev) Added tmp_flush_bb to core_output_filter_ctx_t + * */ #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */ @@ -201,7 +203,7 @@ #ifndef MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_NUMBER_MAJOR 20090401 #endif -#define MODULE_MAGIC_NUMBER_MINOR 1 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 2 /* 0...n */ /** * Determine if the server's current MODULE_MAGIC_NUMBER is at least a diff --git a/include/httpd.h b/include/httpd.h index a7a7025ca8b..cd47b11132c 100644 --- a/include/httpd.h +++ b/include/httpd.h @@ -1241,6 +1241,7 @@ typedef struct core_output_filter_ctx { apr_bucket_brigade *buffered_bb; apr_size_t bytes_in; apr_size_t bytes_written; + apr_bucket_brigade *tmp_flush_bb; } core_output_filter_ctx_t; typedef struct core_filter_ctx { diff --git a/server/core_filters.c b/server/core_filters.c index d9b6eb00ba4..9a54d42b06e 100644 --- a/server/core_filters.c +++ b/server/core_filters.c @@ -396,6 +396,12 @@ apr_status_t ap_core_output_filter(ap_filter_t *f, apr_bucket_brigade *new_bb) if (rv != APR_SUCCESS) { return rv; } + /* + * Need to create tmp brigade with correct lifetime. Passing + * NULL to apr_brigade_split_ex would result in a brigade + * allocated from bb->pool which might be wrong. + */ + ctx->tmp_flush_bb = apr_brigade_create(c->pool, c->bucket_alloc); } if (new_bb != NULL) { @@ -468,7 +474,7 @@ apr_status_t ap_core_output_filter(ap_filter_t *f, apr_bucket_brigade *new_bb) bucket = next) { next = APR_BUCKET_NEXT(bucket); if (APR_BUCKET_IS_FLUSH(bucket)) { - apr_bucket_brigade *remainder = apr_brigade_split(bb, next); + ctx->tmp_flush_bb = apr_brigade_split_ex(bb, next, ctx->tmp_flush_bb); apr_status_t rv = send_brigade_blocking(net->client_socket, bb, &(ctx->bytes_written), c); if (rv != APR_SUCCESS) { @@ -476,7 +482,7 @@ apr_status_t ap_core_output_filter(ap_filter_t *f, apr_bucket_brigade *new_bb) c->aborted = 1; return rv; } - bb = remainder; + APR_BRIGADE_CONCAT(bb, ctx->tmp_flush_bb); next = APR_BRIGADE_FIRST(bb); bytes_in_brigade = 0; non_file_bytes_in_brigade = 0;