r1985 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Sun Sep 23 15:04:20 CEST 2007


Author: phk
Date: 2007-09-23 15:04:20 +0200 (Sun, 23 Sep 2007)
New Revision: 1985

Modified:
   trunk/varnish-cache/bin/varnishd/cache_pool.c
   trunk/varnish-cache/bin/varnishd/hash_classic.c
Log:
Partially revert previous optimization: it wasn't.


Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c	2007-09-23 13:01:21 UTC (rev 1984)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c	2007-09-23 13:04:20 UTC (rev 1985)
@@ -221,22 +221,25 @@
 		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);
+			assert(1 == read(w->pipe[0], &c, 1));
 		}
-
-		UNLOCK(&qp->mtx);
-
 		if (w->wrq == NULL)
-			assert(1 == read(w->pipe[0], &c, 1));
-		if (w->wrq == NULL)
 			break;
 		wrk_do_one(w);
 	}

Modified: trunk/varnish-cache/bin/varnishd/hash_classic.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/hash_classic.c	2007-09-23 13:01:21 UTC (rev 1984)
+++ trunk/varnish-cache/bin/varnishd/hash_classic.c	2007-09-23 13:04:20 UTC (rev 1985)
@@ -121,13 +121,14 @@
 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 @@
 			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 @@
 		he2->head = hp;
 
 		noh->hashpriv = he2;
+		AZ(noh->hash);
 		noh->hash = malloc(sp->lhashptr);
 		XXXAN(noh->hash);
 		noh->hashlen = sp->lhashptr;




More information about the varnish-commit mailing list