[experimental-ims] 66bc91d Merge master -> experimental-ims
Geoff Simmons
geoff at varnish-cache.org
Mon Jan 30 16:09:53 CET 2012
commit 66bc91da9513da5350964f051d2eca585ab8b113
Merge: c766bc8 58e4a20
Author: Geoff Simmons <geoff at uplex.de>
Date: Mon Jan 30 16:09:23 2012 +0100
Merge master -> experimental-ims
diff --cc bin/varnishd/cache/cache_center.c
index 398996d,3286abf..48d53a7
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@@ -657,21 -634,14 +646,20 @@@ cnt_fetch(struct sess *sp, struct worke
wrk->busyobj->exp.ttl = -1.;
AZ(wrk->busyobj->do_esi);
-
+ AZ(wrk->busyobj->do_pass);
+
VCL_fetch_method(sp);
+ /* Cancel streaming if a stale object was validated */
+ /* XXX: But not if original beresp.status != 304 */
+ /* See also AZ(sp->stale_obj) in cnt_streambody() */
+ if (sp->stale_obj)
+ wrk->busyobj->do_stream = 0;
+
+ if (req->objcore != NULL && wrk->busyobj->do_pass)
+ req->objcore->flags |= OC_F_PASS;
+
switch (req->handling) {
- case VCL_RET_HIT_FOR_PASS:
- if (req->objcore != NULL)
- req->objcore->flags |= OC_F_PASS;
- sp->step = STP_FETCHBODY;
- return (0);
case VCL_RET_DELIVER:
AssertObjCorePassOrBusy(req->objcore);
sp->step = STP_FETCHBODY;
@@@ -807,33 -774,29 +792,33 @@@ cnt_fetchbody(struct sess *sp, struct w
"Content-Encoding: gzip");
/* But we can't do both at the same time */
- assert(wrk->busyobj->do_gzip == 0 || wrk->busyobj->do_gunzip == 0);
+ assert(bo->do_gzip == 0 || bo->do_gunzip == 0);
/* ESI takes precedence and handles gzip/gunzip itself */
- if (wrk->busyobj->do_esi)
- wrk->busyobj->vfp = &vfp_esi;
- else if (wrk->busyobj->do_gunzip)
- wrk->busyobj->vfp = &vfp_gunzip;
- else if (wrk->busyobj->do_gzip)
- wrk->busyobj->vfp = &vfp_gzip;
- else if (wrk->busyobj->is_gzip)
- wrk->busyobj->vfp = &vfp_testgzip;
-
- if (wrk->busyobj->do_esi || req->esi_level > 0)
- wrk->busyobj->do_stream = 0;
+ if (bo->do_esi)
+ bo->vfp = &vfp_esi;
+ else if (bo->do_gunzip)
+ bo->vfp = &vfp_gunzip;
+ else if (bo->do_gzip)
+ bo->vfp = &vfp_gzip;
+ else if (bo->is_gzip)
+ bo->vfp = &vfp_testgzip;
+
+ if (bo->do_esi || req->esi_level > 0)
+ bo->do_stream = 0;
if (!req->wantbody)
- wrk->busyobj->do_stream = 0;
+ bo->do_stream = 0;
/* No reason to try streaming a non-existing body */
- if (wrk->busyobj->body_status == BS_NONE)
- wrk->busyobj->do_stream = 0;
+ if (bo->body_status == BS_NONE)
+ bo->do_stream = 0;
- l = http_EstimateWS(wrk->busyobj->beresp,
+ l = http_EstimateWS(bo->beresp,
pass ? HTTPH_R_PASS : HTTPH_A_INS, &nhttp);
+ if (sp->stale_obj) {
+ l += http_EstimateWS(sp->stale_obj->http, 0, &stale_nhttp);
+ nhttp += stale_nhttp;
+ }
/* Create Vary instructions */
if (req->objcore != NULL) {
@@@ -877,12 -840,10 +862,12 @@@
}
CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC);
+ wrk->busyobj->exp.keep = req->exp.keep;
+
req->storage_hint = NULL;
- if (wrk->busyobj->do_gzip ||
- (wrk->busyobj->is_gzip && !wrk->busyobj->do_gunzip))
+ if (bo->do_gzip ||
+ (bo->is_gzip && !bo->do_gunzip))
req->obj->gziped = 1;
if (vary != NULL) {
@@@ -905,11 -866,10 +890,11 @@@
http_FilterResp(sp, hp, hp2, pass ? HTTPH_R_PASS : HTTPH_A_INS);
http_CopyHome(wrk, sp->vsl_id, hp2);
- if (http_GetHdr(hp, H_Last_Modified, &b))
+ if (http_GetHdr(hp, H_Last_Modified, &b)
+ || http_GetHdr(req->obj->http, H_Last_Modified, &b))
req->obj->last_modified = VTIM_parse(b);
else
- req->obj->last_modified = floor(wrk->busyobj->exp.entered);
+ req->obj->last_modified = floor(bo->exp.entered);
assert(WRW_IsReleased(wrk));
@@@ -933,30 -893,11 +918,30 @@@
/* Use unmodified headers*/
i = FetchBody(wrk, req->obj);
+ /*
+ * If a stale_obj was found, dup its storage into the new obj,
+ * reset Content-Length from the size of the storage, and discard
+ * the stale_obj.
+ */
+ if (sp->stale_obj) {
+ STV_dup(sp, sp->stale_obj, req->obj);
+ assert(sp->stale_obj->len == req->obj->len);
+
+ http_Unset(req->obj->http, H_Content_Length);
+ http_PrintfHeader(sp->wrk, sp->fd, req->obj->http,
+ "Content-Length: %u", req->obj->len);
+
+ EXP_Clr(&sp->stale_obj->exp);
+ EXP_Rearm(sp->stale_obj);
+ HSH_Deref(sp->wrk, NULL, &sp->stale_obj);
+ AZ(sp->stale_obj);
+ }
+
- http_Setup(wrk->busyobj->bereq, NULL);
- http_Setup(wrk->busyobj->beresp, NULL);
- wrk->busyobj->vfp = NULL;
+ http_Setup(bo->bereq, NULL);
+ http_Setup(bo->beresp, NULL);
+ bo->vfp = NULL;
assert(WRW_IsReleased(wrk));
- AZ(wrk->busyobj->vbc);
+ AZ(bo->vbc);
AN(req->director);
if (i) {
More information about the varnish-commit
mailing list