Commit 0862868d authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Inject persistent objects into the EXP engine.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4128 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 11834535
......@@ -487,6 +487,7 @@ extern pthread_t cli_thread;
/* cache_expiry.c */
void EXP_Insert(struct object *o);
void EXP_Inject(struct objcore *oc, struct objcore_head *lru, double ttl);
void EXP_Init(void);
void EXP_Rearm(const struct object *o);
int EXP_Touch(const struct object *o);
......
......@@ -89,6 +89,31 @@ update_object_when(const struct object *o)
return (1);
}
/*--------------------------------------------------------------------
* Object has been added to cache, record in lru & binheap.
*
* We grab a reference to the object, which will keep it around until
* we decide its time to let it go.
*/
void
EXP_Inject(struct objcore *oc, struct objcore_head *lru, double ttl)
{
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
Lck_Lock(&exp_mtx);
assert(oc->timer_idx == BINHEAP_NOIDX);
oc->timer_when = ttl;
binheap_insert(exp_heap, oc);
assert(oc->timer_idx != BINHEAP_NOIDX);
if (lru != NULL) {
VTAILQ_INSERT_TAIL(lru, oc, lru_list);
oc->flags |= OC_F_ONLRU;
}
Lck_Unlock(&exp_mtx);
}
/*--------------------------------------------------------------------
* Object has been added to cache, record in lru & binheap.
*
......
......@@ -408,8 +408,6 @@ HSH_Insert(const struct sess *sp)
/* NB: do not deref objhead the new object inherits our reference */
Lck_Unlock(&oh->mtx);
sp->wrk->stats->n_object++;
/* XXX: Insert in EXP */
return (oc);
}
......
......@@ -800,6 +800,7 @@ smp_load_seg(struct sess *sp, const struct smp_sc *sc, struct smp_seg *sg)
uint64_t length;
struct smp_segment *ss;
struct smp_object *so;
struct objcore *oc;
uint32_t no;
double t_now = TIM_real();
struct smp_signctx ctx[1];
......@@ -819,13 +820,15 @@ smp_load_seg(struct sess *sp, const struct smp_sc *sc, struct smp_seg *sg)
if (so->ttl < t_now)
continue;
HSH_Prealloc(sp);
sp->wrk->nobjcore->flags |= OC_F_PERSISTENT;
sp->wrk->nobjcore->flags &= ~OC_F_BUSY;
sp->wrk->nobjcore->obj = (void*)so;
sp->wrk->nobjcore->smp_seg = sg;
sp->wrk->nobjcore->ban = BAN_RefBan(so->ban, sc->tailban);
oc = sp->wrk->nobjcore;
oc->flags |= OC_F_PERSISTENT;
oc->flags &= ~OC_F_BUSY;
oc->obj = (void*)so;
oc->smp_seg = sg;
oc->ban = BAN_RefBan(so->ban, sc->tailban);
memcpy(sp->wrk->nobjhead->digest, so->hash, SHA256_LEN);
(void)HSH_Insert(sp);
EXP_Inject(oc, NULL, so->ttl);
sg->nalloc++;
}
WRK_SumStat(sp->wrk);
......
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