]> err.no Git - varnish/commitdiff
Partially revert previous optimization: it wasn't.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sun, 23 Sep 2007 13:04:20 +0000 (13:04 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sun, 23 Sep 2007 13:04:20 +0000 (13:04 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1985 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_pool.c
varnish-cache/bin/varnishd/hash_classic.c

index 15c35e1a7f35f46fc076060f409fdca1e455823b..3bdbc3989448025796e9306884d2c6e170f221cb 100644 (file)
@@ -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);
index a52f86671ba7b1cb20c5e18fbb3b997b5a4d651e..ec8d6077735e06c521fff03d3f38dc4c9079a542 100644 (file)
@@ -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;