From: Cliff Woolley Date: Wed, 13 Jun 2001 16:48:37 +0000 (+0000) Subject: * apr_brigade_partition() now returns an apr_status_t (finally!). X-Git-Tag: 2.0.19~75 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c091130eab8ad5d5f21ad86e10fe808bc264fc0b;p=thirdparty%2Fapache%2Fhttpd.git * apr_brigade_partition() now returns an apr_status_t (finally!). * did some code cleanups/optimizations in that function. * updated Apache's byterange filter to handle the new prototype. added error handling to the byterange filter should apr_brigade_partition() ever fail, which it never will unless somebody either removes the earlier call to apr_brigade_length() for some unknown reason or invents a new bucket type that is of a predetermined length but which cannot be split natively (or which has a split that might fail). might as well be future-proof. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@89363 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index b5e6b4b107a..176dcf6dbaa 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -2227,6 +2227,8 @@ static int use_range_x(request_rec *r) } #define BYTERANGE_FMT "%" APR_OFF_T_FMT "-%" APR_OFF_T_FMT "/%" APR_OFF_T_FMT +#define PARTITION_ERR_FMT "apr_brigade_partition() failed " \ + "[%" APR_OFF_T_FMT ",%" APR_OFF_T_FMT "]" AP_CORE_DECLARE_NONSTD(apr_status_t) ap_byterange_filter( ap_filter_t *f, @@ -2320,11 +2322,24 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_byterange_filter( if (rv == -1) { continue; - } - else { - found = 1; } + /* these calls to apr_brigade_partition() should theoretically + * never fail because of the above call to apr_brigade_length(), + * but what the heck, we'll check for an error anyway */ + if ((rv = apr_brigade_partition(bb, range_start, &ec)) != APR_SUCCESS) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, + PARTITION_ERR_FMT, range_start, clength); + continue; + } + if ((rv = apr_brigade_partition(bb, range_end+1, &e2)) != APR_SUCCESS) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, + PARTITION_ERR_FMT, range_end+1, clength); + continue; + } + + found = 1; + if (ctx->num_ranges > 1) { char *ts; @@ -2339,10 +2354,6 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_byterange_filter( APR_BRIGADE_INSERT_TAIL(bsend, e); } - e = apr_brigade_partition(bb, range_start); - e2 = apr_brigade_partition(bb, range_end + 1); - - ec = e; do { apr_bucket *foo; const char *str;