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

Assign obj.keep and obj.grace from defaults on obj creation.

Losse EXP_Grace() and EXP_Keep() functions
parent 6cb94654
......@@ -904,7 +904,6 @@ void EXP_Set_grace(struct exp *e, double v);
void EXP_Set_keep(struct exp *e, double v);
double EXP_Ttl(const struct req *, const struct object*);
double EXP_Grace(const struct req *, const struct object*);
void EXP_Insert(const struct object *o, double now);
void EXP_Inject(struct objcore *oc, struct lru *lru, double when);
void EXP_Init(void);
......
......@@ -107,28 +107,6 @@ EXP_ACCESS(keep, 0.,)
* adjusted for defaults and by per-session limits.
*/
static double
EXP_Keep(const struct req *req, const struct object *o)
{
double r;
r = (double)cache_param->default_keep;
if (o->exp.keep > 0.)
r = o->exp.keep;
return (EXP_Ttl(req, o) + r);
}
double
EXP_Grace(const struct req *req, const struct object *o)
{
double r;
r = (double)cache_param->default_grace;
if (o->exp.grace >= 0.)
r = o->exp.grace;
return (EXP_Ttl(req, o) + r);
}
double
EXP_Ttl(const struct req *req, const struct object *o)
{
......@@ -148,17 +126,14 @@ static int
update_object_when(const struct object *o)
{
struct objcore *oc;
double when, w2;
double when;
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
oc = o->objcore;
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
Lck_AssertHeld(&exp_mtx);
when = EXP_Keep(NULL, o);
w2 = EXP_Grace(NULL, o);
if (w2 > when)
when = w2;
when = o->exp.t_origin + o->exp.ttl + o->exp.grace + o->exp.keep;
assert(!isnan(when));
if (when == oc->timer_when)
return (0);
......
......@@ -79,8 +79,9 @@ RFC2616_Ttl(struct busyobj *bo)
assert(bo->t_fetch != 0.0 && !isnan(bo->t_fetch));
expp->t_origin = bo->t_fetch;
/* If all else fails, cache using default ttl */
expp->ttl = cache_param->default_ttl;
expp->grace = cache_param->default_grace;
expp->keep = cache_param->default_keep;
max_age = age = 0;
h_expires = 0;
......
......@@ -547,7 +547,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->ttl = EXP_Grace(NULL, o);
so->ttl = oc->timer_when;
so->ptr = (uint8_t*)o - sc->base;
so->ban = BAN_Time(oc->ban);
......
......@@ -480,7 +480,6 @@ smp_oc_updatemeta(struct objcore *oc)
struct object *o;
struct smp_seg *sg;
struct smp_object *so;
double mttl;
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
o = smp_oc_getobj(NULL, oc);
......@@ -490,17 +489,15 @@ smp_oc_updatemeta(struct objcore *oc)
CHECK_OBJ_NOTNULL(sg->sc, SMP_SC_MAGIC);
so = smp_find_so(sg, oc->priv2);
mttl = EXP_Grace(NULL, o);
if (sg == sg->sc->cur_seg) {
/* Lock necessary, we might race close_seg */
Lck_Lock(&sg->sc->mtx);
so->ban = BAN_Time(oc->ban);
so->ttl = mttl;
so->ttl = oc->timer_when;
Lck_Unlock(&sg->sc->mtx);
} else {
so->ban = BAN_Time(oc->ban);
so->ttl = mttl;
so->ttl = oc->timer_when;
}
}
......
......@@ -13,6 +13,9 @@ varnish v1 \
-storage "-spersistent,${tmpdir}/_.per,10m" \
-vcl+backend { } -start
varnish v1 -cliok "param.set default_grace 0"
varnish v1 -cliok "param.set default_keep 0"
client c1 {
txreq -url "/"
rxresp
......
......@@ -11,6 +11,8 @@ server s1 {
} -start
varnish v1 -vcl+backend { } -start
varnish v1 -cliok "param.set default_grace 0"
varnish v1 -cliok "param.set default_keep 0"
client c1 {
txreq -url "/"
......
......@@ -12,6 +12,9 @@ server s1 {
varnish v1 -vcl+backend { } -start
varnish v1 -cliok "param.set default_keep 0"
varnish v1 -cliok "param.set default_grace 0"
client c1 {
txreq -url "/"
rxresp
......
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