Index: client_side.c
===================================================================
RCS file: /squid/squid/src/client_side.c,v
retrieving revision 1.490
diff -u -r1.490 client_side.c
--- client_side.c 2000/06/27 22:05:59 1.490
+++ client_side.c 2000/07/13 08:05:40
@@ -1088,7 +1088,6 @@
HttpHeader *hdr = rep ? &rep->header : 0;
const char *range_err = NULL;
request_t *request = http->request;
- int is_hit = isTcpHit(http->log_type);
assert(request->range);
/* check if we still want to do ranges */
if (!rep)
@@ -1109,9 +1108,6 @@
range_err = "too complex range header";
else if (!request->flags.cachable) /* from we_do_ranges in http.c */
range_err = "non-cachable request";
- else if (!is_hit && Config.rangeOffsetLimit < httpHdrRangeFirstOffset(request->range)
- && Config.rangeOffsetLimit != -1) /* from we_do_ranges in http.c */
- range_err = "range outside range_offset_limit";
/* get rid of our range specs on error */
if (range_err) {
debug(33, 3) ("clientBuildRangeHeader: will not do ranges: %s.\n", range_err);
@@ -1927,6 +1923,50 @@
errorAppendEntry(http->entry, err);
}
+/*
+ * 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.
+ */
+static int
+clientCheckRangeOffsetLimit(StoreEntry *entry, HttpHdrRange *range)
+{
+ ssize_t range_start;
+ /*
+ * If the range offset limit is disabled, don't force a miss.
+ */
+ if (-1 == Config.rangeOffsetLimit)
+ 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
+ * whole object cached, we won't force a miss.
+ */
+ if (STORE_OK == entry->store_status)
+ return 0; /* we have the whole object */
+ /*
+ * Now we have a hit on a PENDING object. We need to see
+ * if the part we want is already cached. If so, we don't
+ * force a miss.
+ */
+ assert(NULL != entry->mem_obj);
+ if (range_start <= entry->mem_obj->inmem_hi)
+ return 0;
+ /*
+ * Even though we have a PENDING copy of the object, we
+ * don't want to wait to reach the first range offset,
+ * so we force a miss for a new range request to the
+ * origin.
+ */
+ return 1;
+}
+
static log_type
clientProcessRequest2(clientHttpRequest * http)
{
@@ -1993,6 +2033,12 @@
*/
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)) {
+ debug(33, 1) ("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: http.c
===================================================================
RCS file: /squid/squid/src/http.c,v
retrieving revision 1.363
diff -u -r1.363 http.c
--- http.c 2000/06/27 22:06:02 1.363
+++ http.c 2000/07/13 08:05:41
@@ -661,8 +661,15 @@
* serving this request, so it is better to forward ranges to
* the server and fetch only the requested content)
*/
- we_do_ranges =
- orig_request->range && orig_request->flags.cachable && !httpHdrRangeWillBeComplex(orig_request->range) && (Config.rangeOffsetLimit == -1 || httpHdrRangeFirstOffset(orig_request->range) <= Config.rangeOffsetLimit);
+ if (NULL == orig_request->range)
+ we_do_ranges = 0;
+ else if (!orig_request->flags.cachable)
+ we_do_ranges = 0;
+ else if (orig_request->flags.we_dont_do_ranges)
+ we_do_ranges = 0;
+ else
+ we_do_ranges = 1;
+debug(0,0)("%s:%d: we_do_ranges=%d\n", __FILE__,__LINE__,we_do_ranges);
debug(11, 8) ("httpBuildRequestHeader: range specs: %p, cachable: %d; we_do_ranges: %d\n",
orig_request->range, orig_request->flags.cachable, we_do_ranges);
Index: structs.h
===================================================================
RCS file: /squid/squid/src/structs.h,v
retrieving revision 1.346
diff -u -r1.346 structs.h
--- structs.h 2000/06/27 08:41:31 1.346
+++ structs.h 2000/07/13 08:05:43
@@ -1438,6 +1438,7 @@
#endif
unsigned int accelerated:1;
unsigned int internal:1;
+ unsigned int we_dont_do_ranges:1;
};
struct _link_list {
Received on Thu Jul 13 2000 - 02:20:32 MDT
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:12:32 MST