From 7c80fc1359976fe8c40103f4d4defa94d11bef32 Mon Sep 17 00:00:00 2001 From: phk Date: Sun, 23 Sep 2007 13:04:20 +0000 Subject: [PATCH] Partially revert previous optimization: it wasn't. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1985 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache_pool.c | 25 +++++++++++++---------- varnish-cache/bin/varnishd/hash_classic.c | 12 ++++++++--- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache_pool.c b/varnish-cache/bin/varnishd/cache_pool.c index 15c35e1a..3bdbc398 100644 --- a/varnish-cache/bin/varnishd/cache_pool.c +++ b/varnish-cache/bin/varnishd/cache_pool.c @@ -221,21 +221,24 @@ wrk_thread(void *priv) CHECK_OBJ_NOTNULL(w, WORKER_MAGIC); assert(!isnan(w->used)); - LOCK(&tmtx); - - /* Process overflow requests, if any */ w->wrq = TAILQ_FIRST(&overflow); if (w->wrq != NULL) { - VSL_stats->n_wrk_queue--; - TAILQ_REMOVE(&overflow, w->wrq, list); - } else { + LOCK(&tmtx); + + /* Process overflow requests, if any */ + w->wrq = TAILQ_FIRST(&overflow); + if (w->wrq != NULL) { + VSL_stats->n_wrk_queue--; + TAILQ_REMOVE(&overflow, w->wrq, list); + } + UNLOCK(&tmtx); + } + if (w->wrq == NULL) { + LOCK(&qp->mtx); TAILQ_INSERT_HEAD(&qp->idle, w, list); - } - - UNLOCK(&qp->mtx); - - if (w->wrq == NULL) + UNLOCK(&qp->mtx); assert(1 == read(w->pipe[0], &c, 1)); + } if (w->wrq == NULL) break; wrk_do_one(w); diff --git a/varnish-cache/bin/varnishd/hash_classic.c b/varnish-cache/bin/varnishd/hash_classic.c index a52f8667..ec8d6077 100644 --- a/varnish-cache/bin/varnishd/hash_classic.c +++ b/varnish-cache/bin/varnishd/hash_classic.c @@ -121,13 +121,14 @@ hcl_start(void) static struct objhead * hcl_lookup(struct sess *sp, struct objhead *noh) { + struct objhead *roh; struct hcl_entry *he, *he2; struct hcl_hd *hp; unsigned u1, digest, r; unsigned u, v; int i; - CHECK_OBJ_NOTNULL(noh, OBJHEAD_MAGIC); + CHECK_OBJ_ORNULL(noh, OBJHEAD_MAGIC); digest = ~0U; for (u = 0; u < sp->ihashptr; u += 2) { @@ -158,11 +159,15 @@ hcl_lookup(struct sess *sp, struct objhead *noh) if (i > 0) break; he->refcnt++; - noh = he->oh; + roh = he->oh; UNLOCK(&hp->mtx); if (he2 != NULL) free(he2); - return (noh); + if (noh->hash != NULL) { + free(noh->hash); + noh->hash = NULL; + } + return (roh); } if (noh == NULL) { UNLOCK(&hp->mtx); @@ -189,6 +194,7 @@ hcl_lookup(struct sess *sp, struct objhead *noh) he2->head = hp; noh->hashpriv = he2; + AZ(noh->hash); noh->hash = malloc(sp->lhashptr); XXXAN(noh->hash); noh->hashlen = sp->lhashptr; -- 2.39.5