Commit 8e470933 authored by Cliff Woolley's avatar Cliff Woolley
Browse files

* 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
parent 8751e389
Loading
Loading
Loading
Loading
+18 −7
Original line number Diff line number Diff line
@@ -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,
@@ -2321,9 +2323,22 @@ 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;