From: Jeff Trawick Date: Tue, 10 Oct 2000 17:04:19 +0000 (+0000) Subject: minor cleanups in http_filter() and ap_get_client_block() X-Git-Tag: APACHE_2_0_ALPHA_8~423 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bead96c345b040eb1ef726dc2f6ead9c3dd4366f;p=apache minor cleanups in http_filter() and ap_get_client_block() this is not the change to allow us to read broken-up header lines again :( . http_filter() - respect apr_status_t as set by bucket->read() or ap_get_brigade() - return apr_status_t instead of length . ap_get_client_block() - remove a confusing line which set the length parameter before - passing it to bucket->read() git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86517 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index 282842102c..646e3d40e8 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -858,9 +858,9 @@ API_EXPORT(const char *) ap_method_name_of(int methnum) typedef struct http_filter_ctx { ap_bucket_brigade *b; - int c_len; } http_ctx_t; -int http_filter(ap_filter_t *f, ap_bucket_brigade *b) + +apr_status_t http_filter(ap_filter_t *f, ap_bucket_brigade *b) { #define ASCII_CR '\015' #define ASCII_LF '\012' @@ -871,19 +871,23 @@ int http_filter(ap_filter_t *f, ap_bucket_brigade *b) int state = 0; http_ctx_t *ctx = f->ctx; ap_bucket_brigade *bb; - + apr_status_t rv; if (!ctx) { f->ctx = ctx = apr_pcalloc(f->c->pool, sizeof(*ctx)); - ap_get_brigade(f->next, b); + if ((rv = ap_get_brigade(f->next, b)) != APR_SUCCESS) { + return rv; + } } else { if (ctx->b) { AP_BRIGADE_CONCAT(b, ctx->b); - ctx->b = NULL; + ctx->b = NULL; /* XXX we just leaked a brigade structure */ } else { - ap_get_brigade(f->next, b); + if ((rv = ap_get_brigade(f->next, b)) != APR_SUCCESS) { + return rv; + } } } @@ -902,17 +906,20 @@ int http_filter(ap_filter_t *f, ap_bucket_brigade *b) bb = ap_brigade_split(b, AP_BUCKET_NEXT(e)); f->c->remaining = remain; ctx->b = bb; - return length; + return APR_SUCCESS; } else { + f->c->remaining = remain; ctx->b = NULL; - return length; + return APR_SUCCESS; } } AP_BRIGADE_FOREACH(e, b) { - e->read(e, (const char **)&buff, &length, 0); + if ((rv = e->read(e, (const char **)&buff, &length, 0)) != APR_SUCCESS) { + return rv; + } pos = buff + 1; while (pos < buff + length) { @@ -936,7 +943,7 @@ int http_filter(ap_filter_t *f, ap_bucket_brigade *b) e->split(e, pos - buff); bb = ap_brigade_split(b, AP_BUCKET_NEXT(e)); ctx->b = bb; - return length; + return APR_SUCCESS; } } } @@ -2464,7 +2471,6 @@ API_EXPORT(long) ap_get_client_block(request_rec *r, char *buffer, int bufsiz) } } while (AP_BRIGADE_EMPTY(r->connection->input_data)); - len_read = len_to_read; rv = b->read(b, &tempbuf, &len_read, 0); if (len_to_read < b->length) { b->split(b, len_to_read);