]> granicus.if.org Git - apache/commitdiff
* Lower memory usage by reusing the brigade instead of constantly
authorRuediger Pluem <rpluem@apache.org>
Mon, 14 Sep 2009 19:46:36 +0000 (19:46 +0000)
committerRuediger Pluem <rpluem@apache.org>
Mon, 14 Sep 2009 19:46:36 +0000 (19:46 +0000)
  recerating one.

Submitted by: Stefan Fritsch <sf sfritsch.de>
Reviewed by: rpluem

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@814807 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
include/ap_mmn.h
include/httpd.h
server/core_filters.c

diff --git a/CHANGES b/CHANGES
index 3762ea7d134d9f84eb911583f85286afcb775603..854d4af3238085755eed073833b7e8b2ce08c0d7 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
 
 Changes with Apache 2.3.3
 
+  *) core: Lower memory usage of core output filter.
+     [Stefan Fritsch <sf sfritsch.de>]
+
   *) mod_mime: Detect invalid use of MultiviewsMatch inside Location and
      LocationMatch sections.  PR47754. [Dan Poirier]
 
index e23b71a4a730c3c22294d017461e99f52ac4de96..5a655e460dad1fa434e44eb8ac71bb50993912da 100644 (file)
  *                         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" */
 #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
index a7a7025ca8bf12cdaa3fba2e0a85b34625010801..cd47b11132c70e22762589b552fd7467f73a49fb 100644 (file)
@@ -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 {
index d9b6eb00ba45b3e4bdb5f64c332f5d461a44afac..9a54d42b06eae14ecf6fee2ac8b496c499613262 100644 (file)
@@ -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;