httpd-apreq-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pgollu...@apache.org
Subject svn commit: r477619 - in /httpd/apreq/branches/v2_09: CHANGES include/apreq_util.h include/apreq_version.h library/util.c
Date Tue, 21 Nov 2006 10:57:44 GMT
Author: pgollucci
Date: Tue Nov 21 02:57:44 2006
New Revision: 477619

URL: http://svn.apache.org/viewvc?view=rev&rev=477619
Log:
backport r477025 from trunk


Modified:
    httpd/apreq/branches/v2_09/CHANGES
    httpd/apreq/branches/v2_09/include/apreq_util.h
    httpd/apreq/branches/v2_09/include/apreq_version.h
    httpd/apreq/branches/v2_09/library/util.c

Modified: httpd/apreq/branches/v2_09/CHANGES
URL: http://svn.apache.org/viewvc/httpd/apreq/branches/v2_09/CHANGES?view=diff&rev=477619&r1=477618&r2=477619
==============================================================================
--- httpd/apreq/branches/v2_09/CHANGES (original)
+++ httpd/apreq/branches/v2_09/CHANGES Tue Nov 21 02:57:44 2006
@@ -4,7 +4,11 @@
 
 @section v2_09 Changes with libapreq2-2.09 (September 7, 2006)
 
--Build [Philip M. Gollucci]
+- C API [joes]
+  Fix leak associated to calling apreq_brigade_fwrite() on an upload
+  brigade.
+
+- Build [Philip M. Gollucci]
   SunOS (Solaris) 
   Users must use gmake not make for building.
 

Modified: httpd/apreq/branches/v2_09/include/apreq_util.h
URL: http://svn.apache.org/viewvc/httpd/apreq/branches/v2_09/include/apreq_util.h?view=diff&rev=477619&r1=477618&r2=477619
==============================================================================
--- httpd/apreq/branches/v2_09/include/apreq_util.h (original)
+++ httpd/apreq/branches/v2_09/include/apreq_util.h Tue Nov 21 02:57:44 2006
@@ -270,8 +270,8 @@
  * @return Error status code from either an unsuccessful apr_bucket_read(),
  *         or a failed apr_file_writev().
  *
- * @remarks       In the future, this function may do something
- *                intelligent with file buckets.
+ * @remarks       This function leaks a bucket brigade into bb->p whenever
+ *                the final bucket in bb is a spool bucket.
  */
 
 APREQ_DECLARE(apr_status_t) apreq_brigade_fwrite(apr_file_t *f,

Modified: httpd/apreq/branches/v2_09/include/apreq_version.h
URL: http://svn.apache.org/viewvc/httpd/apreq/branches/v2_09/include/apreq_version.h?view=diff&rev=477619&r1=477618&r2=477619
==============================================================================
--- httpd/apreq/branches/v2_09/include/apreq_version.h (original)
+++ httpd/apreq/branches/v2_09/include/apreq_version.h Tue Nov 21 02:57:44 2006
@@ -62,7 +62,7 @@
 #define APREQ_MINOR_VERSION       6
 
 /** patch level */
-#define APREQ_PATCH_VERSION       1
+#define APREQ_PATCH_VERSION       2
 
 /**
  *  This symbol is defined for internal, "development" copies of libapreq.

Modified: httpd/apreq/branches/v2_09/library/util.c
URL: http://svn.apache.org/viewvc/httpd/apreq/branches/v2_09/library/util.c?view=diff&rev=477619&r1=477618&r2=477619
==============================================================================
--- httpd/apreq/branches/v2_09/library/util.c (original)
+++ httpd/apreq/branches/v2_09/library/util.c Tue Nov 21 02:57:44 2006
@@ -771,43 +771,6 @@
 }
 
 
-APREQ_DECLARE(apr_status_t) apreq_brigade_fwrite(apr_file_t *f,
-                                                 apr_off_t *wlen,
-                                                 apr_bucket_brigade *bb)
-{
-    struct iovec v[APREQ_DEFAULT_NELTS];
-    apr_status_t s;
-    apr_bucket *e;
-    int n = 0;
-    *wlen = 0;
-
-    for (e = APR_BRIGADE_FIRST(bb); e != APR_BRIGADE_SENTINEL(bb);
-         e = APR_BUCKET_NEXT(e))
-    {
-        apr_size_t len;
-        if (n == APREQ_DEFAULT_NELTS) {
-            s = apreq_fwritev(f, v, &n, &len);
-            if (s != APR_SUCCESS)
-                return s;
-            *wlen += len;
-        }
-        s = apr_bucket_read(e, (const char **)&(v[n].iov_base),
-                            &len, APR_BLOCK_READ);
-        if (s != APR_SUCCESS)
-            return s;
-
-        v[n++].iov_len = len;
-    }
-
-    while (n > 0) {
-        apr_size_t len;
-        s = apreq_fwritev(f, v, &n, &len);
-        if (s != APR_SUCCESS)
-            return s;
-        *wlen += len;
-    }
-    return APR_SUCCESS;
-}
 
 
 struct cleanup_data {
@@ -1153,3 +1116,60 @@
     return s;
 }
 
+APREQ_DECLARE(apr_status_t) apreq_brigade_fwrite(apr_file_t *f,
+                                                 apr_off_t *wlen,
+                                                 apr_bucket_brigade *bb)
+{
+    struct iovec v[APREQ_DEFAULT_NELTS];
+    apr_status_t s;
+    apr_bucket *e, *first;
+    int n = 0;
+    *wlen = 0;
+    apr_bucket_brigade *tmp = bb;
+
+    if (BUCKET_IS_SPOOL(APR_BRIGADE_LAST(bb))) {
+        tmp = apr_brigade_create(bb->p, bb->bucket_alloc);
+
+        s = apreq_brigade_copy(tmp, bb);
+        if (s != APR_SUCCESS)
+            return s;
+    }
+
+    for (e = APR_BRIGADE_FIRST(tmp); e != APR_BRIGADE_SENTINEL(tmp);
+         e = APR_BUCKET_NEXT(e))
+    {
+        apr_size_t len;
+        if (n == APREQ_DEFAULT_NELTS) {
+            s = apreq_fwritev(f, v, &n, &len);
+            if (s != APR_SUCCESS)
+                return s;
+
+            if (tmp != bb) {
+                while ((first = APR_BRIGADE_FIRST(tmp)) != e)
+                    apr_bucket_delete(first);
+            }
+
+            *wlen += len;
+        }
+        s = apr_bucket_read(e, (const char **)&(v[n].iov_base),
+                            &len, APR_BLOCK_READ);
+        if (s != APR_SUCCESS)
+            return s;
+
+        v[n++].iov_len = len;
+    }
+
+    while (n > 0) {
+        apr_size_t len;
+        s = apreq_fwritev(f, v, &n, &len);
+        if (s != APR_SUCCESS)
+            return s;
+        *wlen += len;
+
+        if (tmp != bb) {
+            while ((first = APR_BRIGADE_FIRST(tmp)) != e)
+                apr_bucket_delete(first);
+        }
+    }
+    return APR_SUCCESS;
+}



Mime
View raw message