From 7540257a1302034646646d9ab7defc1a43d6dfdb Mon Sep 17 00:00:00 2001 From: phk Date: Fri, 20 Feb 2009 18:00:06 +0000 Subject: [PATCH] Add a lot more paranoia asserts git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3798 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache_expire.c | 1 + varnish-cache/bin/varnishd/cache_hash.c | 5 +++++ varnish-cache/bin/varnishd/cache_pool.c | 8 +++++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache_expire.c b/varnish-cache/bin/varnishd/cache_expire.c index 41f4804d..35d97366 100644 --- a/varnish-cache/bin/varnishd/cache_expire.c +++ b/varnish-cache/bin/varnishd/cache_expire.c @@ -251,6 +251,7 @@ exp_timer(void *arg) o = oc->obj; CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); + CHECK_OBJ_NOTNULL(o->objhead, OBJHEAD_MAGIC); assert(oc->timer_idx != BINHEAP_NOIDX); binheap_delete(exp_heap, oc->timer_idx); assert(oc->timer_idx == BINHEAP_NOIDX); diff --git a/varnish-cache/bin/varnishd/cache_hash.c b/varnish-cache/bin/varnishd/cache_hash.c index 70c7bf31..961adc74 100644 --- a/varnish-cache/bin/varnishd/cache_hash.c +++ b/varnish-cache/bin/varnishd/cache_hash.c @@ -356,6 +356,7 @@ HSH_Lookup(struct sess *sp) WSP(sp, SLT_Debug, "on waiting list <%s>", oh->hash); sp->objhead = oh; + sp->wrk = NULL; Lck_Unlock(&oh->mtx); return (NULL); } @@ -393,10 +394,14 @@ hsh_rush(struct objhead *oh) unsigned u; struct sess *sp; + CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); + Lck_AssertHeld(&oh->mtx); for (u = 0; u < params->rush_exponent; u++) { sp = VTAILQ_FIRST(&oh->waitinglist); if (sp == NULL) return; + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + AZ(sp->wrk); VTAILQ_REMOVE(&oh->waitinglist, sp, list); DSL(0x20, SLT_Debug, sp->id, "off waiting list"); WRK_QueueSession(sp); diff --git a/varnish-cache/bin/varnishd/cache_pool.c b/varnish-cache/bin/varnishd/cache_pool.c index e555ef07..1db99e18 100644 --- a/varnish-cache/bin/varnishd/cache_pool.c +++ b/varnish-cache/bin/varnishd/cache_pool.c @@ -330,10 +330,8 @@ wrk_thread(void *priv) w->lastused = TIM_real(); VTAILQ_INSERT_HEAD(&qp->idle, w, list); if (!stats_clean) { - Lck_Lock(&wstat_mtx); - wrk_sumstat(w); + WRK_SumStat(w); stats_clean = 1; - Lck_Unlock(&wstat_mtx); } Lck_CondWait(&w->cond, &qp->mtx); } @@ -348,6 +346,7 @@ wrk_thread(void *priv) AZ(w->wfd); assert(w->wlp == w->wlb); w->wrq = NULL; + HSH_Cleanup(w); if (!Lck_Trylock(&wstat_mtx)) { wrk_sumstat(w); stats_clean = 1; @@ -430,6 +429,7 @@ wrk_do_cnt_sess(struct worker *w, void *priv) struct sess *sess; CAST_OBJ_NOTNULL(sess, priv, SESS_MAGIC); + AZ(sess->wrk); THR_SetSession(sess); sess->wrk = w; CHECK_OBJ_ORNULL(w->nobj, OBJECT_MAGIC); @@ -445,6 +445,8 @@ wrk_do_cnt_sess(struct worker *w, void *priv) void WRK_QueueSession(struct sess *sp) { + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + AZ(sp->wrk); sp->workreq.func = wrk_do_cnt_sess; sp->workreq.priv = sp; if (WRK_Queue(&sp->workreq) == 0) -- 2.39.5