[master] e654cc8 Move busyobj->exp to bo->fetch_objcore->exp

Poul-Henning Kamp phk at FreeBSD.org
Thu Jun 26 17:03:03 CEST 2014


commit e654cc8a7b6b9103201be957a36931a39fea610a
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Jun 26 10:54:55 2014 +0000

    Move busyobj->exp to bo->fetch_objcore->exp

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 60d7b26..9854cc8 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -425,6 +425,8 @@ struct objcore {
 	struct busyobj		*busyobj;
 	double			timer_when;
 
+	struct exp		exp;
+
 	uint16_t		flags;
 #define OC_F_BUSY		(1<<1)
 #define OC_F_PASS		(1<<2)
@@ -553,7 +555,6 @@ struct busyobj {
 	struct objcore		*fetch_objcore;
 	struct object		*fetch_obj;
 
-	struct exp		exp;
 	struct http_conn	htc;
 
 	struct pool_task	fetch_task;
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 1a34043..1b824d5 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -49,13 +49,15 @@ static struct object *
 vbf_allocobj(struct busyobj *bo, unsigned l, uint16_t nhttp)
 {
 	struct object *obj;
+	struct objcore *oc;
 	const char *storage_hint;
 	double lifetime;
 
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
-	CHECK_OBJ_NOTNULL(bo->fetch_objcore, OBJCORE_MAGIC);
+	oc = bo->fetch_objcore;
+	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 
-	lifetime = bo->exp.ttl + bo->exp.grace + bo->exp.keep;
+	lifetime = oc->exp.ttl + oc->exp.grace + oc->exp.keep;
 
 	if (bo->uncacheable || lifetime < cache_param->shortlived)
 		storage_hint = TRANSIENT_STORAGE;
@@ -77,10 +79,10 @@ vbf_allocobj(struct busyobj *bo, unsigned l, uint16_t nhttp)
 	 * on Transient storage.
 	 */
 
-	if (bo->exp.ttl > cache_param->shortlived)
-		bo->exp.ttl = cache_param->shortlived;
-	bo->exp.grace = 0.0;
-	bo->exp.keep = 0.0;
+	if (oc->exp.ttl > cache_param->shortlived)
+		oc->exp.ttl = cache_param->shortlived;
+	oc->exp.grace = 0.0;
+	oc->exp.keep = 0.0;
 	obj = STV_NewObject(bo, TRANSIENT_STORAGE, l, nhttp);
 	return (obj);
 }
@@ -162,7 +164,7 @@ vbf_beresp2obj(struct busyobj *bo)
 	if (http_GetHdr(hp, H_Last_Modified, &b))
 		obj->last_modified = VTIM_parse(b);
 	else
-		obj->last_modified = floor(bo->exp.t_origin);
+		obj->last_modified = floor(bo->fetch_objcore->exp.t_origin);
 
 	/* Disassociate the obj from the bo's workspace */
 	hp2->ws = NULL;
@@ -348,12 +350,12 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
 	/*
 	 * What does RFC2616 think about TTL ?
 	 */
-	EXP_Clr(&bo->exp);
+	EXP_Clr(&bo->fetch_objcore->exp);
 	RFC2616_Ttl(bo, now);
 
 	/* private objects have negative TTL */
 	if (bo->fetch_objcore->flags & OC_F_PRIVATE)
-		bo->exp.ttl = -1.;
+		bo->fetch_objcore->exp.ttl = -1.;
 
 	AZ(bo->do_esi);
 
@@ -696,10 +698,10 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo)
 	http_PrintfHeader(bo->beresp, "Date: %s", time_str);
 	http_SetHeader(bo->beresp, "Server: Varnish");
 
-	bo->exp.t_origin = bo->t_prev;
-	bo->exp.ttl = 0;
-	bo->exp.grace = 0;
-	bo->exp.keep = 0;
+	bo->fetch_objcore->exp.t_origin = bo->t_prev;
+	bo->fetch_objcore->exp.ttl = 0;
+	bo->fetch_objcore->exp.grace = 0;
+	bo->fetch_objcore->exp.keep = 0;
 
 	VCL_backend_error_method(bo->vcl, wrk, NULL, bo, bo->bereq->ws);
 
diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c
index bb0a85e..8ada968 100644
--- a/bin/varnishd/cache/cache_rfc2616.c
+++ b/bin/varnishd/cache/cache_rfc2616.c
@@ -72,7 +72,7 @@ RFC2616_Ttl(struct busyobj *bo, double now)
 	struct exp *expp;
 
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
-	expp = &bo->exp;
+	expp = &bo->fetch_objcore->exp;
 
 	hp = bo->beresp;
 
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index c11f2d9..9533f75 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -486,12 +486,12 @@ VRT_DO_EXP_R(obj, ctx->req->obj->exp, ttl,
 VRT_DO_EXP_R(obj, ctx->req->obj->exp, grace, 0)
 VRT_DO_EXP_R(obj, ctx->req->obj->exp, keep, 0)
 
-VRT_DO_EXP_L(beresp, ctx->bo->exp, ttl)
-VRT_DO_EXP_R(beresp, ctx->bo->exp, ttl, 0)
-VRT_DO_EXP_L(beresp, ctx->bo->exp, grace)
-VRT_DO_EXP_R(beresp, ctx->bo->exp, grace, 0)
-VRT_DO_EXP_L(beresp, ctx->bo->exp, keep)
-VRT_DO_EXP_R(beresp, ctx->bo->exp, keep, 0)
+VRT_DO_EXP_L(beresp, ctx->bo->fetch_objcore->exp, ttl)
+VRT_DO_EXP_R(beresp, ctx->bo->fetch_objcore->exp, ttl, 0)
+VRT_DO_EXP_L(beresp, ctx->bo->fetch_objcore->exp, grace)
+VRT_DO_EXP_R(beresp, ctx->bo->fetch_objcore->exp, grace, 0)
+VRT_DO_EXP_L(beresp, ctx->bo->fetch_objcore->exp, keep)
+VRT_DO_EXP_R(beresp, ctx->bo->fetch_objcore->exp, keep, 0)
 
 /*--------------------------------------------------------------------
  * [be]req.xid
diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c
index cf75a48..ce9c007 100644
--- a/bin/varnishd/storage/stevedore.c
+++ b/bin/varnishd/storage/stevedore.c
@@ -286,7 +286,7 @@ STV_MkObject(struct stevedore *stv, struct busyobj *bo,
 
 	HTTP_Setup(o->http, bo->ws_o, bo->vsl, SLT_ObjMethod);
 	o->http->magic = HTTP_MAGIC;
-	o->exp = bo->exp;
+	o->exp = bo->fetch_objcore->exp;
 	VTAILQ_INIT(&o->store);
 
 	o->objcore = bo->fetch_objcore;
@@ -344,6 +344,7 @@ STV_NewObject(struct busyobj *bo, const char *hint,
 	int i;
 
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+	CHECK_OBJ_NOTNULL(bo->fetch_objcore, OBJCORE_MAGIC);
 	assert(wsl > 0);
 	wsl = PRNDUP(wsl);
 
diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c
index fcff5be..008afe7 100644
--- a/bin/varnishd/storage/storage_persistent.c
+++ b/bin/varnishd/storage/storage_persistent.c
@@ -517,10 +517,13 @@ smp_allocobj(struct stevedore *stv, struct busyobj *bo,
 	unsigned objidx;
 
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
-	if (bo->fetch_objcore == NULL)
-		return (NULL);		/* from cnt_error */
 	CAST_OBJ_NOTNULL(sc, stv->priv, SMP_SC_MAGIC);
-	AN((bo->exp.ttl + bo->exp.grace + bo->exp.keep) > 0.);
+
+	/* Don't entertain already dead objects */
+	if ((bo->fetch_objcore->exp.ttl +
+	     bo->fetch_objcore->exp.grace +
+	     bo->fetch_objcore->exp.keep) <= 0.)
+		return (NULL);
 
 	ltot = IRNUP(sc, ltot);
 
@@ -546,7 +549,7 @@ smp_allocobj(struct stevedore *stv, struct busyobj *bo,
 	/* We have to do this somewhere, might as well be here... */
 	assert(sizeof so->hash == DIGEST_LEN);
 	memcpy(so->hash, oc->objhead->digest, DIGEST_LEN);
-	so->exp = bo->exp;
+	so->exp = bo->fetch_objcore->exp;
 	so->ptr = (uint8_t*)o - sc->base;
 	so->ban = BAN_Time(oc->ban);
 



More information about the varnish-commit mailing list