]> granicus.if.org Git - apache/commitdiff
Merge r1833014 from trunk:
authorJim Jagielski <jim@apache.org>
Tue, 19 Jun 2018 13:15:49 +0000 (13:15 +0000)
committerJim Jagielski <jim@apache.org>
Tue, 19 Jun 2018 13:15:49 +0000 (13:15 +0000)
* modules/http/http_request.c (ap_process_request_after_handler,
  ap_process_request): Cache and retrieve the brigade structure used
  to send EOR and FLUSH between requests in c->pool userdata, to avoid
  allocating a brigade structure per-request out of c->pool.

Submitted by: rpluem, jorton

Submitted by: jorton
Reviewed by: jorton, covener, jim

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1833841 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
modules/http/http_request.c

diff --git a/CHANGES b/CHANGES
index 3e00881fdebbcb9e6fb2ec0c750ef2cfa1eb60ec..cc74c694650ec823103a28dccaab2d7b657033d3 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.4.34
 
+  *) http: Fix small memory leak per request when handling persistent
+     connections.  [Ruediger Pluem, Joe Orton]
+
   *) mod_proxy_html: Fix variable interpolation and memory allocation failure
      in ProxyHTMLURLMap.  [Ewald Dieterich <ewald mailbox.org>]
 
diff --git a/STATUS b/STATUS
index 52d2f2838952865a26341b9cff284b904d08a94d..72de52c17fa45c9cd9c3508d71537a74b4bd4b1e 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -141,11 +141,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-  *) http: Fix small memory leak per request when handling persistent connections
-     trunk patch: http://svn.apache.org/r1833014
-     2.4.x patch: trunk works (modulo CHANGES)
-                  svn merge -c 1833014 ^/httpd/httpd/trunk . 
-     +1: jorton, covener, jim
 
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
   [ New proposals should be added at the end of the list ]
index ba16622d74c762dd3790e3fe29fb274c499bf6f6..9e7c4dbc5f5fbdac3e3c91f153afa2e999f19c89 100644 (file)
@@ -345,6 +345,16 @@ AP_DECLARE(apr_status_t) ap_check_pipeline(conn_rec *c, apr_bucket_brigade *bb,
     return rv;
 }
 
+#define RETRIEVE_BRIGADE_FROM_POOL(bb, key, pool, allocator) do {       \
+    apr_pool_userdata_get((void **)&bb, key, pool);                     \
+    if (bb == NULL) {                                                   \
+        bb = apr_brigade_create(pool, allocator);                       \
+        apr_pool_userdata_setn((const void *)bb, key, NULL, pool);      \
+    }                                                                   \
+    else {                                                              \
+        apr_brigade_cleanup(bb);                                        \
+    }                                                                   \
+} while(0)
 
 AP_DECLARE(void) ap_process_request_after_handler(request_rec *r)
 {
@@ -357,7 +367,8 @@ AP_DECLARE(void) ap_process_request_after_handler(request_rec *r)
      * this bucket is destroyed, the request will be logged and
      * its pool will be freed
      */
-    bb = apr_brigade_create(c->pool, c->bucket_alloc);
+    RETRIEVE_BRIGADE_FROM_POOL(bb, "ap_process_request_after_handler_brigade",
+                               c->pool, c->bucket_alloc);
     b = ap_bucket_eor_create(c->bucket_alloc, r);
     APR_BRIGADE_INSERT_HEAD(bb, b);
 
@@ -383,7 +394,7 @@ AP_DECLARE(void) ap_process_request_after_handler(request_rec *r)
      */
     rv = ap_check_pipeline(c, bb, DEFAULT_LIMIT_BLANK_LINES);
     c->data_in_input_filters = (rv == APR_SUCCESS);
-    apr_brigade_destroy(bb);
+    apr_brigade_cleanup(bb);
 
     if (c->cs)
         c->cs->state = (c->aborted) ? CONN_STATE_LINGER
@@ -477,7 +488,8 @@ AP_DECLARE(void) ap_process_request(request_rec *r)
     ap_process_async_request(r);
 
     if (!c->data_in_input_filters) {
-        bb = apr_brigade_create(c->pool, c->bucket_alloc);
+        RETRIEVE_BRIGADE_FROM_POOL(bb, "ap_process_request_brigade", 
+                                   c->pool, c->bucket_alloc);
         b = apr_bucket_flush_create(c->bucket_alloc);
         APR_BRIGADE_INSERT_HEAD(bb, b);
         rv = ap_pass_brigade(c->output_filters, bb);
@@ -490,6 +502,7 @@ AP_DECLARE(void) ap_process_request(request_rec *r)
             ap_log_cerror(APLOG_MARK, APLOG_INFO, rv, c, APLOGNO(01581)
                           "flushing data to the client");
         }
+        apr_brigade_cleanup(bb);
     }
     if (ap_extended_status) {
         ap_time_process_request(c->sbh, STOP_PREQUEST);