Commit 299b3b8f authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Do the simple part of ban list lurker: link the objcores off the bans

the reference.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4205 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 4323eb9b
......@@ -291,6 +291,7 @@ struct objcore {
unsigned timer_idx;
VTAILQ_ENTRY(objcore) list;
VTAILQ_ENTRY(objcore) lru_list;
VTAILQ_ENTRY(objcore) ban_list;
struct smp_seg *smp_seg;
struct ban *ban;
};
......@@ -470,7 +471,7 @@ int BAN_CheckObject(struct object *o, const struct sess *sp);
void BAN_Reload(double t0, unsigned flags, const char *ban);
struct ban *BAN_TailRef(void);
void BAN_Compile(void);
struct ban *BAN_RefBan(double t0, const struct ban *tail);
struct ban *BAN_RefBan(struct objcore *oc, double t0, const struct ban *tail);
void BAN_Deref(struct ban **ban);
/* cache_center.c [CNT] */
......
......@@ -81,6 +81,7 @@ BAN_New(void)
return (NULL);
}
VTAILQ_INIT(&b->tests);
VTAILQ_INIT(&b->objcore);
return (b);
}
......@@ -103,6 +104,9 @@ BAN_Free(struct ban *b)
struct ban_test *bt;
CHECK_OBJ_NOTNULL(b, BAN_MAGIC);
AZ(b->refcount);
assert(VTAILQ_EMPTY(&b->objcore));
if (b->vsb != NULL)
vsb_delete(b->vsb);
if (b->test != NULL)
......@@ -365,10 +369,12 @@ BAN_NewObj(struct object *o)
{
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
CHECK_OBJ_NOTNULL(o->objcore, OBJCORE_MAGIC);
AZ(o->ban);
Lck_Lock(&ban_mtx);
o->ban = ban_start;
ban_start->refcount++;
VTAILQ_INSERT_TAIL(&ban_start->objcore, o->objcore, ban_list);
Lck_Unlock(&ban_mtx);
o->ban_t = o->ban->t0;
}
......@@ -402,6 +408,7 @@ BAN_DestroyObj(struct object *o)
Lck_Lock(&ban_mtx);
assert(o->ban->refcount > 0);
o->ban->refcount--;
VTAILQ_REMOVE(&o->ban->objcore, o->objcore, ban_list);
o->ban = NULL;
/* Attempt to purge last ban entry */
......@@ -449,8 +456,11 @@ BAN_CheckObject(struct object *o, const struct sess *sp)
Lck_Lock(&ban_mtx);
o->ban->refcount--;
if (b == o->ban) /* not banned */
VTAILQ_REMOVE(&o->ban->objcore, o->objcore, ban_list);
if (b == o->ban) { /* not banned */
VTAILQ_INSERT_TAIL(&b0->objcore, o->objcore, ban_list);
b0->refcount++;
}
VSL_stats->n_purge_obj_test++;
VSL_stats->n_purge_re_test += tests;
Lck_Unlock(&ban_mtx);
......@@ -511,7 +521,7 @@ BAN_TailRef(void)
*/
struct ban *
BAN_RefBan(double t0, const struct ban *tail)
BAN_RefBan(struct objcore *oc, double t0, const struct ban *tail)
{
struct ban *b;
......@@ -525,6 +535,7 @@ BAN_RefBan(double t0, const struct ban *tail)
assert(b->t0 == t0);
Lck_Lock(&ban_mtx);
b->refcount++;
VTAILQ_INSERT_TAIL(&b->objcore, oc, ban_list);
Lck_Unlock(&ban_mtx);
return (b);
}
......
......@@ -58,6 +58,7 @@ struct ban {
#define BAN_F_GONE (1 << 0)
#define BAN_F_PENDING (1 << 1)
VTAILQ_HEAD(,ban_test) tests;
VTAILQ_HEAD(,objcore) objcore;
double t0;
struct vsb *vsb;
char *test;
......
......@@ -510,10 +510,9 @@ cnt_fetch(struct sess *sp)
sp->objcore->objhead = sp->objhead;
sp->objhead = NULL; /* refcnt follows pointer. */
sp->objcore = NULL; /* refcnt follows pointer. */
BAN_NewObj(sp->obj);
}
BAN_NewObj(sp->obj);
sp->obj->xid = sp->xid;
sp->obj->response = sp->err_code;
sp->obj->cacheable = sp->wrk->cacheable;
......
......@@ -688,7 +688,8 @@ HSH_Deref(const struct worker *w, struct object **oo)
if (r != 0)
return;
BAN_DestroyObj(o);
if (oh != NULL)
BAN_DestroyObj(o);
AZ(o->ban);
DSL(0x40, SLT_Debug, 0, "Object %u workspace min free %u",
o->xid, WS_Free(o->ws_o));
......
......@@ -830,7 +830,7 @@ smp_load_seg(struct sess *sp, const struct smp_sc *sc, struct smp_seg *sg)
oc->flags &= ~OC_F_BUSY;
oc->obj = (void*)so;
oc->smp_seg = sg;
oc->ban = BAN_RefBan(so->ban, sc->tailban);
oc->ban = BAN_RefBan(oc, so->ban, sc->tailban);
memcpy(sp->wrk->nobjhead->digest, so->hash, SHA256_LEN);
(void)HSH_Insert(sp);
EXP_Inject(oc, NULL, so->ttl);
......
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