]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
* apr_brigade_partition() now returns an apr_status_t (finally!).
authorCliff Woolley <jwoolley@apache.org>
Wed, 13 Jun 2001 16:48:37 +0000 (16:48 +0000)
committerCliff Woolley <jwoolley@apache.org>
Wed, 13 Jun 2001 16:48:37 +0000 (16:48 +0000)
* 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

modules/http/http_protocol.c

index b5e6b4b107ab39303ecad728311b3e3d992675c7..176dcf6dbaa9a355713909398c41c8221f43894c 100644 (file)
@@ -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;