From 4c6709cf92e3196451cbc7b168103ab855e0508e Mon Sep 17 00:00:00 2001 From: Justin Erenkrantz Date: Sun, 31 Aug 2003 16:14:39 +0000 Subject: [PATCH] Resolve the ap_get_client_block() showstopper by looking at APR_BRIGADE_LAST of what we get from ap_get_brigade and set a nugget for our next call to pick up on. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@101141 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 +++ STATUS | 5 +---- modules/http/http_protocol.c | 20 +++++++++++++++++++- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index 75fb5ea719..40e9ff3758 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ Changes with Apache 2.1.0-dev [Remove entries to the current 2.0 section below, when backported] + *) Modify ap_get_client_block() to note if it has seen EOS. + [Justin Erenkrantz] + *) The bucket brigades subsystem now honors the MaxMemFree setting. [Cliff Woolley, Jean-Jacques Clar] diff --git a/STATUS b/STATUS index abb555d428..2856232b48 100644 --- a/STATUS +++ b/STATUS @@ -1,5 +1,5 @@ APACHE 2.1 STATUS: -*-text-*- -Last modified at [$Date: 2003/08/06 04:02:34 $] +Last modified at [$Date: 2003/08/31 16:14:38 $] Release [NOTE that only Alpha/Beta releases occur in 2.1 development]: @@ -28,9 +28,6 @@ RELEASE SHOWSTOPPERS: * the edge connection filter cannot be removed http://marc.theaimsgroup.com/?l=apache-httpd-dev&m=105366252619530&w=2 - * bug in ap_get_client_block (wrong handling of EOS) - http://marc.theaimsgroup.com/?l=apache-httpd-dev&m=105281649228629&w=2 - CURRENT VOTES: * Promote mod_cache from experimental to non-experimental diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index 61cb7f6eea..6749f82815 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -1910,6 +1910,10 @@ AP_DECLARE(long) ap_get_client_block(request_rec *r, char *buffer, apr_status_t rv; apr_bucket_brigade *bb; + if (r->remaining < 0 || (!r->read_chunked && r->remaining == 0)) { + return 0; + } + bb = apr_brigade_create(r->pool, r->connection->bucket_alloc); if (bb == NULL) { r->connection->keepalive = AP_CONN_CLOSE; @@ -1936,7 +1940,21 @@ AP_DECLARE(long) ap_get_client_block(request_rec *r, char *buffer, * returning data when requested. */ AP_DEBUG_ASSERT(!APR_BRIGADE_EMPTY(bb)); - + + /* Check to see if EOS in the brigade. + * + * If so, we have to leave a nugget for the *next* ap_get_client_block + * call to return 0. + */ + if (APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(bb))) { + if (r->read_chunked) { + r->remaining = -1; + } + else { + r->remaining = 0; + } + } + rv = apr_brigade_flatten(bb, buffer, &bufsiz); if (rv != APR_SUCCESS) { apr_brigade_destroy(bb); -- 2.40.0