Return-Path: Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 32035 invoked by uid 500); 27 Jan 2002 07:30:08 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 32024 invoked by uid 500); 27 Jan 2002 07:30:08 -0000 Delivered-To: apmail-httpd-2.0-cvs@apache.org Date: 27 Jan 2002 07:30:03 -0000 Message-ID: <20020127073003.50996.qmail@icarus.apache.org> From: brianp@apache.org To: httpd-2.0-cvs@apache.org Subject: cvs commit: httpd-2.0/server protocol.c X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N brianp 02/01/26 23:30:03 Modified: server protocol.c Log: Fixed a read from a deleted brigade in the new version of ap_rgetline()... In the "folding" case, there was an ap_get_brigade() call after the brigade had been destroyed. I noticed this while debugging a memory leak that showed up while testing the httpd with ab. Revision Changes Path 1.74 +10 -3 httpd-2.0/server/protocol.c Index: protocol.c =================================================================== RCS file: /home/cvs/httpd-2.0/server/protocol.c,v retrieving revision 1.73 retrieving revision 1.74 diff -u -r1.73 -r1.74 --- protocol.c 26 Jan 2002 23:01:31 -0000 1.73 +++ protocol.c 27 Jan 2002 07:30:02 -0000 1.74 @@ -289,9 +289,6 @@ bytes_handled += len; } - /* We no longer need the returned brigade. */ - apr_brigade_destroy(b); - /* We likely aborted early before reading anything or we read no * data. Technically, this might be success condition. But, * probably means something is horribly wrong. For now, we'll @@ -299,6 +296,7 @@ */ if (bytes_handled == 0) { *read = 0; + apr_brigade_destroy(b); return APR_SUCCESS; } @@ -324,6 +322,7 @@ rv = ap_rgetline(&tmp, next_size, &next_len, r, fold); if (rv != APR_SUCCESS) { + apr_brigade_destroy(b); return rv; } @@ -343,6 +342,7 @@ last_char = *s + bytes_handled - 1; } else { + apr_brigade_destroy(b); return APR_ENOSPC; } } @@ -390,6 +390,7 @@ APR_BLOCK_READ, 1); if (rv != APR_SUCCESS) { + apr_brigade_destroy(b); return rv; } @@ -398,12 +399,14 @@ /* If we see an EOS, don't bother doing anything more. */ if (APR_BUCKET_IS_EOS(e)) { *read = bytes_handled; + apr_brigade_destroy(b); return APR_SUCCESS; } rv = apr_bucket_read(e, &str, &len, APR_BLOCK_READ); if (rv != APR_SUCCESS) { + apr_brigade_destroy(b); return rv; } @@ -434,6 +437,7 @@ rv = ap_rgetline(&tmp, next_size, &next_len, r, fold); if (rv != APR_SUCCESS) { + apr_brigade_destroy(b); return rv; } @@ -450,9 +454,11 @@ } *read = bytes_handled + next_len; + apr_brigade_destroy(b); return APR_SUCCESS; } else { + apr_brigade_destroy(b); return APR_ENOSPC; } } @@ -461,6 +467,7 @@ /* FIXME: Can we optimize this at all by placing it a different layer? */ ap_xlate_proto_from_ascii(*s, bytes_handled); *read = bytes_handled; + apr_brigade_destroy(b); return APR_SUCCESS; }