Return-Path: Delivered-To: apmail-httpd-apreq-cvs-archive@www.apache.org Received: (qmail 1105 invoked from network); 21 Nov 2006 10:58:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 21 Nov 2006 10:58:21 -0000 Received: (qmail 83611 invoked by uid 500); 21 Nov 2006 10:58:29 -0000 Delivered-To: apmail-httpd-apreq-cvs-archive@httpd.apache.org Received: (qmail 83589 invoked by uid 500); 21 Nov 2006 10:58:29 -0000 Mailing-List: contact apreq-cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: apreq-dev@httpd.apache.org List-Post: List-Help: List-Unsubscribe: List-Id: Delivered-To: mailing list apreq-cvs@httpd.apache.org Received: (qmail 83575 invoked by uid 99); 21 Nov 2006 10:58:29 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Nov 2006 02:58:29 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Nov 2006 02:58:18 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id D68BA1A9846; Tue, 21 Nov 2006 02:57:44 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: apreq-cvs@httpd.apache.org From: pgollucci@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061121105744.D68BA1A9846@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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; +}