httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pque...@apache.org
Subject svn commit: r154200 - in httpd/httpd/trunk: CHANGES include/httpd.h server/core_filters.c
Date Thu, 17 Feb 2005 22:53:10 GMT
Author: pquerna
Date: Thu Feb 17 14:53:07 2005
New Revision: 154200

URL: http://svn.apache.org/viewcvs?view=rev&rev=154200
Log:
*) include/httpd.h: Add a brigade for temporary uses in the core input filter context.
*) server/core_filters.c: Do not use brigade_split, since it allocates a new brigade. Instead
move buckets to our tmpbb, and reuse the tmpbb for every call.

PR: 33382

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/include/httpd.h
    httpd/httpd/trunk/server/core_filters.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/CHANGES?view=diff&r1=154199&r2=154200
==============================================================================
--- httpd/httpd/trunk/CHANGES (original)
+++ httpd/httpd/trunk/CHANGES Thu Feb 17 14:53:07 2005
@@ -2,6 +2,11 @@
 
   [Remove entries to the current 2.0 section below, when backported]
 
+  *) core_input_filter: Move buckets to a persistent brigade instead of
+     creating a new brigade when apr_brigade_split is called. This stops
+     a memory leak when proxying a Streaming Media Server. PR 33382.
+     [Paul Querna]
+
   *) mod_ssl: Add ssl_ext_lookup optional function for accessing
      certificate extensions.   [David Reid, Joe Orton]
 

Modified: httpd/httpd/trunk/include/httpd.h
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/include/httpd.h?view=diff&r1=154199&r2=154200
==============================================================================
--- httpd/httpd/trunk/include/httpd.h (original)
+++ httpd/httpd/trunk/include/httpd.h Thu Feb 17 14:53:07 2005
@@ -1143,6 +1143,7 @@
  
 typedef struct core_filter_ctx {
     apr_bucket_brigade *b;
+    apr_bucket_brigade *tmpbb;
 } core_ctx_t;
  
 typedef struct core_net_rec {

Modified: httpd/httpd/trunk/server/core_filters.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/server/core_filters.c?view=diff&r1=154199&r2=154200
==============================================================================
--- httpd/httpd/trunk/server/core_filters.c (original)
+++ httpd/httpd/trunk/server/core_filters.c Thu Feb 17 14:53:07 2005
@@ -109,6 +109,27 @@
     } while (!APR_BRIGADE_EMPTY(b) && (e != APR_BRIGADE_SENTINEL(b))); \
 } while (0)
 
+
+/**
+ * Split the contents of a brigade after bucket 'e' to an existing brigade
+ *
+ * XXXX: Should this function be added to APR-Util?
+ */
+static void brigade_move(apr_bucket_brigade *b, apr_bucket_brigade *a,
+                         apr_bucket *e)
+{
+    apr_bucket *f;     
+
+    if (e != APR_BRIGADE_SENTINEL(b)) {
+        f = APR_RING_LAST(&b->list);
+        APR_RING_UNSPLICE(e, f, link);
+        APR_RING_SPLICE_HEAD(&a->list, e, f, apr_bucket, link);
+    }
+
+    APR_BRIGADE_CHECK_CONSISTENCY(a);
+    APR_BRIGADE_CHECK_CONSISTENCY(b);
+}
+
 int ap_core_input_filter(ap_filter_t *f, apr_bucket_brigade *b,
                          ap_input_mode_t mode, apr_read_type_e block,
                          apr_off_t readbytes)
@@ -138,7 +159,7 @@
     {
         ctx = apr_pcalloc(f->c->pool, sizeof(*ctx));
         ctx->b = apr_brigade_create(f->c->pool, f->c->bucket_alloc);
-
+        ctx->tmpbb = apr_brigade_create(ctx->b->p, ctx->b->bucket_alloc);
         /* seed the brigade with the client socket. */
         e = apr_bucket_socket_create(net->client_socket, f->c->bucket_alloc);
         APR_BRIGADE_INSERT_TAIL(ctx->b, e);
@@ -290,8 +311,8 @@
             return rv;
         }
 
-        /* Must do split before CONCAT */
-        newbb = apr_brigade_split(ctx->b, e);
+        /* Must do move before CONCAT */
+        brigade_move(ctx->b, ctx->tmpbb, e);
 
         if (mode == AP_MODE_READBYTES) {
             APR_BRIGADE_CONCAT(b, ctx->b);
@@ -312,7 +333,7 @@
         }
 
         /* Take what was originally there and place it back on ctx->b */
-        APR_BRIGADE_CONCAT(ctx->b, newbb);
+        APR_BRIGADE_CONCAT(ctx->b, ctx->tmpbb);
     }
     return APR_SUCCESS;
 }



Mime
View raw message