From 579491a3e9066c1546b387bd05f771f466f4932b Mon Sep 17 00:00:00 2001 From: phk Date: Sat, 23 Feb 2008 19:26:38 +0000 Subject: [PATCH] Rename EXP_TTLchange() to EXP_Rearm() and move binheap check into cache_expire.c. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2530 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache.h | 2 +- varnish-cache/bin/varnishd/cache_expire.c | 13 ++++++++++++- varnish-cache/bin/varnishd/cache_hash.c | 3 +-- varnish-cache/bin/varnishd/cache_vrt.c | 9 +++------ 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index 80f40679..9675b000 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -439,7 +439,7 @@ extern pthread_t cli_thread; /* cache_expiry.c */ void EXP_Insert(struct object *o); void EXP_Init(void); -void EXP_TTLchange(struct object *o); +void EXP_Rearm(struct object *o); void EXP_Touch(struct object *o, double now); int EXP_NukeOne(struct sess *sp); diff --git a/varnish-cache/bin/varnishd/cache_expire.c b/varnish-cache/bin/varnishd/cache_expire.c index dab65673..0406d2ad 100644 --- a/varnish-cache/bin/varnishd/cache_expire.c +++ b/varnish-cache/bin/varnishd/cache_expire.c @@ -115,10 +115,21 @@ EXP_Touch(struct object *o, double now) } } +/*-------------------------------------------------------------------- + * We have changed one or more of the object timers, shuffle it + * accordingly in the binheap + * + * The VCL code can send us here on a non-cached object, just return. + * + * XXX: special case check for ttl = 0 ? + */ + void -EXP_TTLchange(struct object *o) +EXP_Rearm(struct object *o) { + if (o->timer_idx == 0) + return; LOCK(&exp_mtx); if (o->timer_idx != lru_target) { assert(o->timer_idx != 0); /* XXX: symbolic zero ? */ diff --git a/varnish-cache/bin/varnishd/cache_hash.c b/varnish-cache/bin/varnishd/cache_hash.c index 6d68114e..eb62ba2a 100644 --- a/varnish-cache/bin/varnishd/cache_hash.c +++ b/varnish-cache/bin/varnishd/cache_hash.c @@ -210,8 +210,7 @@ HSH_Lookup(struct sess *sp) if (BAN_CheckObject(o, h->hd[HTTP_HDR_URL].b, oh->hash)) { o->ttl = 0; WSP(sp, SLT_ExpBan, "%u was banned", o->xid); - if (o->timer_idx != 0) - EXP_TTLchange(o); + EXP_Rearm(o); continue; } if (o->vary != NULL && !VRY_Match(sp, o->vary)) diff --git a/varnish-cache/bin/varnishd/cache_vrt.c b/varnish-cache/bin/varnishd/cache_vrt.c index 9d8c9cb4..90ed5bae 100644 --- a/varnish-cache/bin/varnishd/cache_vrt.c +++ b/varnish-cache/bin/varnishd/cache_vrt.c @@ -293,8 +293,7 @@ VRT_l_obj_ttl(const struct sess *sp, double a) if (a < 0) a = 0; sp->obj->ttl = sp->t_req + a; - if (sp->obj->timer_idx != 0) - EXP_TTLchange(sp->obj); + EXP_Rearm(sp->obj); } double @@ -318,8 +317,7 @@ VRT_l_obj_grace(const struct sess *sp, double a) if (a < 0) a = 0; sp->obj->grace = a; - if (sp->obj->timer_idx != 0) - EXP_TTLchange(sp->obj); + EXP_Rearm(sp->obj); } double @@ -355,8 +353,7 @@ VRT_l_obj_prefetch(const struct sess *sp, double a) WSL(sp->wrk, SLT_VCL_info, sp->id, "XID %u: obj.prefetch (%g) less than ttl (%g), ignored.", sp->obj->xid, a, sp->obj->ttl - sp->t_req); - if (sp->obj->timer_idx != 0) - EXP_TTLchange(sp->obj); + EXP_Rearm(sp->obj); } double -- 2.39.5