Commit e654cc8a authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

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

parent 8070f329
......@@ -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;
......
......@@ -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);
......
......@@ -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;
......
......@@ -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
......
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment