You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apreq-cvs@httpd.apache.org by jo...@apache.org on 2006/11/20 04:56:08 UTC
svn commit: r477025 - in /httpd/apreq/trunk: CHANGES include/apreq_util.h
include/apreq_version.h library/util.c
Author: joes
Date: Sun Nov 19 19:56:08 2006
New Revision: 477025
URL: http://svn.apache.org/viewvc?view=rev&rev=477025
Log:
Fix leak associated to calling apreq_brigade_fwrite() on an upload
brigade.
Modified:
httpd/apreq/trunk/CHANGES
httpd/apreq/trunk/include/apreq_util.h
httpd/apreq/trunk/include/apreq_version.h
httpd/apreq/trunk/library/util.c
Modified: httpd/apreq/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/apreq/trunk/CHANGES?view=diff&rev=477025&r1=477024&r2=477025
==============================================================================
--- httpd/apreq/trunk/CHANGES (original)
+++ httpd/apreq/trunk/CHANGES Sun Nov 19 19:56:08 2006
@@ -6,7 +6,11 @@
@section v2_09 Changes with libapreq2-2.09 ()
--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/trunk/include/apreq_util.h
URL: http://svn.apache.org/viewvc/httpd/apreq/trunk/include/apreq_util.h?view=diff&rev=477025&r1=477024&r2=477025
==============================================================================
--- httpd/apreq/trunk/include/apreq_util.h (original)
+++ httpd/apreq/trunk/include/apreq_util.h Sun Nov 19 19:56:08 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/trunk/include/apreq_version.h
URL: http://svn.apache.org/viewvc/httpd/apreq/trunk/include/apreq_version.h?view=diff&rev=477025&r1=477024&r2=477025
==============================================================================
--- httpd/apreq/trunk/include/apreq_version.h (original)
+++ httpd/apreq/trunk/include/apreq_version.h Sun Nov 19 19:56:08 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/trunk/library/util.c
URL: http://svn.apache.org/viewvc/httpd/apreq/trunk/library/util.c?view=diff&rev=477025&r1=477024&r2=477025
==============================================================================
--- httpd/apreq/trunk/library/util.c (original)
+++ httpd/apreq/trunk/library/util.c Sun Nov 19 19:56:08 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;
+}