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

with the prefetch timer out of the way, we do not need the ttl

in objcore, only when the timer fires.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@3783 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 083e7edf
...@@ -262,7 +262,6 @@ struct objcore { ...@@ -262,7 +262,6 @@ struct objcore {
#define OBJCORE_MAGIC 0x4d301302 #define OBJCORE_MAGIC 0x4d301302
struct object *obj; struct object *obj;
double timer_when; double timer_when;
double ttl;
unsigned char flags; unsigned char flags;
#define OC_F_ONLRU (1<<0) #define OC_F_ONLRU (1<<0)
#define OC_F_BUSY (1<<1) #define OC_F_BUSY (1<<1)
...@@ -294,6 +293,7 @@ struct object { ...@@ -294,6 +293,7 @@ struct object {
unsigned len; unsigned len;
double ttl;
double age; double age;
double entered; double entered;
double grace; double grace;
......
...@@ -528,7 +528,7 @@ BAN_CheckObject(struct object *o, const struct sess *sp) ...@@ -528,7 +528,7 @@ BAN_CheckObject(struct object *o, const struct sess *sp)
o->ban = b0; o->ban = b0;
return (0); return (0);
} else { } else {
o->objcore->ttl = 0; o->ttl = 0;
WSP(sp, SLT_ExpBan, "%u was banned", o->xid); WSP(sp, SLT_ExpBan, "%u was banned", o->xid);
EXP_Rearm(o); EXP_Rearm(o);
o->ban = NULL; o->ban = NULL;
......
...@@ -378,7 +378,6 @@ static int ...@@ -378,7 +378,6 @@ static int
cnt_fetch(struct sess *sp) cnt_fetch(struct sess *sp)
{ {
int i; int i;
struct objcore *oc;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC);
...@@ -415,12 +414,10 @@ cnt_fetch(struct sess *sp) ...@@ -415,12 +414,10 @@ cnt_fetch(struct sess *sp)
sp->step = STP_RECV; sp->step = STP_RECV;
return (0); return (0);
case VCL_RET_PASS: case VCL_RET_PASS:
if (sp->obj->objcore != NULL) { if (sp->obj->objcore != NULL)
oc = sp->obj->objcore; sp->obj->objcore->flags |= OC_F_PASS;
oc->flags |= OC_F_PASS; if (sp->obj->ttl - sp->t_req < params->default_ttl)
if (oc->ttl - sp->t_req < params->default_ttl) sp->obj->ttl = sp->t_req + params->default_ttl;
oc->ttl = sp->t_req + params->default_ttl;
}
break; break;
case VCL_RET_DELIVER: case VCL_RET_DELIVER:
break; break;
......
...@@ -90,7 +90,7 @@ update_object_when(const struct object *o) ...@@ -90,7 +90,7 @@ update_object_when(const struct object *o)
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
Lck_AssertHeld(&exp_mtx); Lck_AssertHeld(&exp_mtx);
when = oc->ttl + HSH_Grace(o->grace); when = o->ttl + HSH_Grace(o->grace);
assert(!isnan(when)); assert(!isnan(when));
if (when == oc->timer_when) if (when == oc->timer_when)
return (0); return (0);
...@@ -269,7 +269,7 @@ exp_timer(void *arg) ...@@ -269,7 +269,7 @@ exp_timer(void *arg)
assert(sp->handling == VCL_RET_DISCARD); assert(sp->handling == VCL_RET_DISCARD);
WSL(&ww, SLT_ExpKill, 0, WSL(&ww, SLT_ExpKill, 0,
"%u %d", o->xid, (int)(o->objcore->ttl - t)); "%u %d", o->xid, (int)(o->ttl - t));
Lck_Lock(&exp_mtx); Lck_Lock(&exp_mtx);
assert(oc->timer_idx == BINHEAP_NOIDX); assert(oc->timer_idx == BINHEAP_NOIDX);
VTAILQ_REMOVE(&lru, o->objcore, lru_list); VTAILQ_REMOVE(&lru, o->objcore, lru_list);
......
...@@ -276,7 +276,7 @@ HSH_Lookup(struct sess *sp) ...@@ -276,7 +276,7 @@ HSH_Lookup(struct sess *sp)
} }
if (!o->cacheable) if (!o->cacheable)
continue; continue;
if (oc->ttl == 0) if (o->ttl == 0)
continue; continue;
if (BAN_CheckObject(o, sp)) if (BAN_CheckObject(o, sp))
continue; continue;
...@@ -284,11 +284,11 @@ HSH_Lookup(struct sess *sp) ...@@ -284,11 +284,11 @@ HSH_Lookup(struct sess *sp)
continue; continue;
/* If still valid, use it */ /* If still valid, use it */
if (oc->ttl >= sp->t_req) if (o->ttl >= sp->t_req)
break; break;
/* Remember any matching objects inside their grace period */ /* Remember any matching objects inside their grace period */
if (oc->ttl + HSH_Grace(o->grace) >= sp->t_req) if (o->ttl + HSH_Grace(o->grace) >= sp->t_req)
grace_o = o; grace_o = o;
} }
if (oc == NULL) if (oc == NULL)
...@@ -302,7 +302,7 @@ HSH_Lookup(struct sess *sp) ...@@ -302,7 +302,7 @@ HSH_Lookup(struct sess *sp)
*/ */
if (o == NULL && grace_o != NULL && if (o == NULL && grace_o != NULL &&
grace_o->child != NULL && grace_o->child != NULL &&
grace_o->objcore->ttl + HSH_Grace(sp->grace) >= sp->t_req) grace_o->ttl + HSH_Grace(sp->grace) >= sp->t_req)
o = grace_o; o = grace_o;
if (o != NULL) { if (o != NULL) {
...@@ -381,7 +381,7 @@ HSH_Drop(struct sess *sp) ...@@ -381,7 +381,7 @@ HSH_Drop(struct sess *sp)
assert(o->refcnt > 0); assert(o->refcnt > 0);
if (o->objcore != NULL) { /* Pass has no objcore */ if (o->objcore != NULL) { /* Pass has no objcore */
AN(ObjIsBusy(o)); AN(ObjIsBusy(o));
o->objcore->ttl = 0; o->ttl = 0;
} }
o->cacheable = 0; o->cacheable = 0;
if (o->objcore != NULL) /* Pass has no objcore */ if (o->objcore != NULL) /* Pass has no objcore */
......
...@@ -380,9 +380,9 @@ VRT_l_obj_ttl(const struct sess *sp, double a) ...@@ -380,9 +380,9 @@ VRT_l_obj_ttl(const struct sess *sp, double a)
* We special case and make sure that rounding does not surprise. * We special case and make sure that rounding does not surprise.
*/ */
if (a <= 0) if (a <= 0)
sp->obj->objcore->ttl = sp->t_req - 1; sp->obj->ttl = sp->t_req - 1;
else else
sp->obj->objcore->ttl = sp->t_req + a; sp->obj->ttl = sp->t_req + a;
EXP_Rearm(sp->obj); EXP_Rearm(sp->obj);
} }
...@@ -393,7 +393,7 @@ VRT_r_obj_ttl(const struct sess *sp) ...@@ -393,7 +393,7 @@ VRT_r_obj_ttl(const struct sess *sp)
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */ CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */
if (sp->obj->objcore == NULL) if (sp->obj->objcore == NULL)
return (0.0); return (0.0);
return (sp->obj->objcore->ttl - sp->t_req); return (sp->obj->ttl - sp->t_req);
} }
/*-------------------------------------------------------------------- /*--------------------------------------------------------------------
......
...@@ -198,8 +198,7 @@ RFC2616_cache_policy(const struct sess *sp, const struct http *hp) ...@@ -198,8 +198,7 @@ RFC2616_cache_policy(const struct sess *sp, const struct http *hp)
} }
ttl = RFC2616_Ttl(sp, hp, sp->obj); ttl = RFC2616_Ttl(sp, hp, sp->obj);
if (sp->obj->objcore != NULL) sp->obj->ttl = ttl;
sp->obj->objcore->ttl = ttl;
if (ttl == 0) if (ttl == 0)
sp->obj->cacheable = 0; sp->obj->cacheable = 0;
......
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