From: wessels <> Date: Wed, 4 Oct 2000 21:32:13 +0000 (+0000) Subject: DW: X-Git-Tag: SQUID_3_0_PRE1~1837 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=7b1e21ff895f2bd8fd9c55db46e5319008dfd929;p=thirdparty%2Fsquid.git DW: - 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. --- diff --git a/src/HttpHdrRange.cc b/src/HttpHdrRange.cc index cde1e1cb7a..9a24f8f0e4 100644 --- a/src/HttpHdrRange.cc +++ b/src/HttpHdrRange.cc @@ -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; +} diff --git a/src/client_side.cc b/src/client_side.cc index 8beea9cbbc..5dabd9f162 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -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"); diff --git a/src/http.cc b/src/http.cc index 0474ac81d6..901445aa62 100644 --- a/src/http.cc +++ b/src/http.cc @@ -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; diff --git a/src/protos.h b/src/protos.h index d40b508d91..58a20fbb5c 100644 --- a/src/protos.h +++ b/src/protos.h @@ -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 */ diff --git a/src/structs.h b/src/structs.h index f5017ea7ad..01aa4612d0 100644 --- a/src/structs.h +++ b/src/structs.h @@ -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 {