]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
DW:
authorwessels <>
Wed, 4 Oct 2000 21:32:13 +0000 (21:32 +0000)
committerwessels <>
Wed, 4 Oct 2000 21:32:13 +0000 (21:32 +0000)
 - Fixed range_offset_limit, again.  The problem this time is that
   client_side.c wouldn't set the we_dont_do_ranges flag for normal
   cache misses.  It was only being set for requests that might
   have been hits, but we decided to change to a miss.  I moved half
   of clientCheckRangeOffsetLimit into HttpHdrRange.c and called
   it httpHdrRangeOffsetLimit.  The other half stays in client_side.c
   but is now called clientCheckRangeForceMiss.  Also removed the
   confusing we_dont_do_ranges flag.

src/HttpHdrRange.cc
src/client_side.cc
src/http.cc
src/protos.h
src/structs.h

index cde1e1cb7a687acab8fde434d84b586e22da5efb..9a24f8f0e438947c2c877d88216a39f907df7e4b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpHdrRange.cc,v 1.21 2000/03/06 16:23:28 wessels Exp $
+ * $Id: HttpHdrRange.cc,v 1.22 2000/10/04 15:32:13 wessels Exp $
  *
  * DEBUG: section 64    HTTP Range Header
  * AUTHOR: Alex Rousskov
@@ -471,3 +471,22 @@ httpHdrRangeBoundaryStr(clientHttpRequest * http)
     stringAppend(&b, key, strlen(key));
     return b;
 }
+
+/*  
+ * Return true if the first range offset is larger than the configured
+ * limit.
+ */
+int
+httpHdrRangeOffsetLimit(HttpHdrRange * range)
+{
+    if (NULL == range)
+       /* not a range request */
+       return 0;
+    if (-1 == Config.rangeOffsetLimit)
+       /* disabled */
+       return 0;
+    if (Config.rangeOffsetLimit >= httpHdrRangeFirstOffset(range))
+       /* below the limit */
+       return 0;
+    return 1;
+}
index 8beea9cbbc98a58be79649a08fdf8a4087e2b555..5dabd9f162f8cb1081c05447c74a175c657f0b5b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.502 2000/10/04 03:41:20 wessels Exp $
+ * $Id: client_side.cc,v 1.503 2000/10/04 15:32:13 wessels Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -1935,28 +1935,20 @@ clientProcessOnlyIfCachedMiss(clientHttpRequest * http)
 }
 
 /* 
- * Return true if the first range offset is larger than the configured
- * limit, UNLESS the request is a hit AND the bits we want are in
- * the cache.
+ * Return true if we should force a cache miss on this range request.
+ * entry must be non-NULL.
  */
 static int
-clientCheckRangeOffsetLimit(StoreEntry * entry, HttpHdrRange * range)
+clientCheckRangeForceMiss(StoreEntry * entry, HttpHdrRange * range)
 {
-    ssize_t range_start;
     /*
-     * If the range offset limit is disabled, don't force a miss.
+     * If the range_offset_limit is NOT in effect, there
+     * is no reason to force a miss.
      */
-    if (-1 == Config.rangeOffsetLimit)
+    if (0 == httpHdrRangeOffsetLimit(range))
        return 0;
     /*
-     * If the first range offset is less than the configured limit
-     * we won't force a cache miss.
-     */
-    range_start = httpHdrRangeFirstOffset(range);
-    if (Config.rangeOffsetLimit >= range_start)
-       return 0;
-    /*
-     * Now we know it's possibly a hit.  If we already have the
+     * Here, we know it's possibly a hit.  If we already have the
      * whole object cached, we won't force a miss.
      */
     if (STORE_OK == entry->store_status)
@@ -1967,7 +1959,7 @@ clientCheckRangeOffsetLimit(StoreEntry * entry, HttpHdrRange * range)
      * force a miss.
      */
     assert(NULL != entry->mem_obj);
-    if (range_start <= entry->mem_obj->inmem_hi)
+    if (httpHdrRangeFirstOffset(range) <= entry->mem_obj->inmem_hi)
        return 0;
     /*
      * Even though we have a PENDING copy of the object, we
@@ -2046,12 +2038,10 @@ clientProcessRequest2(clientHttpRequest * http)
         */
        debug(33, 3) ("clientProcessRequest2: complex range MISS\n");
        http->entry = NULL;
-       r->flags.we_dont_do_ranges = 1;
        return LOG_TCP_MISS;
-    } else if (clientCheckRangeOffsetLimit(e, r->range)) {
+    } else if (clientCheckRangeForceMiss(e, r->range)) {
        debug(33, 3) ("clientProcessRequest2: forcing miss due to range_offset_limit\n");
        http->entry = NULL;
-       r->flags.we_dont_do_ranges = 1;
        return LOG_TCP_MISS;
     }
     debug(33, 3) ("clientProcessRequest2: default HIT\n");
index 0474ac81d6882c406b47f1da15eca054f2c481fd..901445aa6223e7613f28c4aebe099f2cb8732ba9 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: http.cc,v 1.366 2000/07/18 06:16:41 wessels Exp $
+ * $Id: http.cc,v 1.367 2000/10/04 15:32:13 wessels Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
@@ -667,7 +667,7 @@ httpBuildRequestHeader(request_t * request,
        we_do_ranges = 0;
     else if (!orig_request->flags.cachable)
        we_do_ranges = 0;
-    else if (orig_request->flags.we_dont_do_ranges)
+    else if (httpHdrRangeOffsetLimit(orig_request->range))
        we_do_ranges = 0;
     else
        we_do_ranges = 1;
index d40b508d912bbfe909b5d86e0c24fb99d0cded5a..58a20fbb5c7acd3f0e1da5d65d73005b973e0aee 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: protos.h,v 1.379 2000/10/04 02:18:49 wessels Exp $
+ * $Id: protos.h,v 1.380 2000/10/04 15:32:13 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -347,6 +347,7 @@ extern int httpHdrRangeIsComplex(const HttpHdrRange * range);
 extern int httpHdrRangeWillBeComplex(const HttpHdrRange * range);
 extern ssize_t httpHdrRangeFirstOffset(const HttpHdrRange * range);
 extern ssize_t httpHdrRangeLowestOffset(const HttpHdrRange * range, ssize_t);
+extern int httpHdrRangeOffsetLimit(HttpHdrRange *);
 
 
 /* Http Content Range Header Field */
index f5017ea7adc13dbbc1ffe8a021e2fa62055d5752..01aa4612d0e72597eebed7d188d6f180d6e2c3b8 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: structs.h,v 1.353 2000/10/04 02:14:54 wessels Exp $
+ * $Id: structs.h,v 1.354 2000/10/04 15:32:14 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -1399,7 +1399,6 @@ struct _request_flags {
 #endif
     unsigned int accelerated:1;
     unsigned int internal:1;
-    unsigned int we_dont_do_ranges:1;
 };
 
 struct _link_list {