From 2a66c93d8861cb9be7149272c84c74fc6775a419 Mon Sep 17 00:00:00 2001 From: Justin Erenkrantz Date: Wed, 6 Feb 2002 02:24:18 +0000 Subject: [PATCH] - Fix up a comment so that it makes more sense and explains why we return APR_EOF instead of an EOS bucket. - Start to try to be nice when we *know* we are EOS by removing the bucket. This is only one case where we could end up with a 0 bucket in ctx->b, but let's remove it and move on. (If the bucket were to return 0 bytes and still have data left to read on blocking mode, it's blantly broken, IMHO) git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@93270 13f79535-47bb-0310-9956-ffa450edef68 --- server/core.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/server/core.c b/server/core.c index 14c7654c04..8dc7ff2308 100644 --- a/server/core.c +++ b/server/core.c @@ -3062,9 +3062,13 @@ static int core_input_filter(ap_filter_t *f, apr_bucket_brigade *b, /* ### This is bad. */ APR_BRIGADE_NORMALIZE(ctx->b); - /* check for empty brigade *AFTER* APR_BRIGADE_NORMALIZE() */ + /* check for empty brigade *AFTER* APR_BRIGADE_NORMALIZE() + * If we have lost our socket bucket (see above), we are EOF. + * + * Ideally, this should be returning SUCCESS with EOS bucket, but + * some higher-up APIs (spec. read_request_line via ap_rgetline) + * want an error code. */ if (APR_BRIGADE_EMPTY(ctx->b)) { - /* hit EOF on socket already */ return APR_EOF; } @@ -3150,6 +3154,22 @@ static int core_input_filter(ap_filter_t *f, apr_bucket_brigade *b, } else if (rv != APR_SUCCESS) { return rv; + } else if (block == APR_BLOCK_READ && len == 0) { + /* We wanted to read some bytes in blocking mode. We read + * 0 bytes. Hence, we now assume we are EOS. + * + * When we are in normal mode, return an EOS bucket to the + * caller. + * When we are in speculative mode, leave ctx->b empty, so + * that the next call returns an EOS bucket. + */ + apr_bucket_delete(e); + + if (mode == AP_MODE_READBYTES) { + e = apr_bucket_eos_create(); + APR_BRIGADE_INSERT_TAIL(b, e); + } + return APR_SUCCESS; } /* We can only return at most what we read. */ -- 2.50.1