[master] 43a7282 More tcp-pool related renaming

Poul-Henning Kamp phk at FreeBSD.org
Thu Oct 5 14:17:06 UTC 2017


commit 43a7282319085e3a7aa9876ff8fa5b61729ccab6
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Oct 5 13:32:30 2017 +0000

    More tcp-pool related renaming

diff --git a/bin/varnishd/cache/cache_tcp_pool.c b/bin/varnishd/cache/cache_tcp_pool.c
index 0fdc57b..fa95b18 100644
--- a/bin/varnishd/cache/cache_tcp_pool.c
+++ b/bin/varnishd/cache/cache_tcp_pool.c
@@ -66,8 +66,8 @@ struct tcp_pool {
 
 };
 
-static struct lock		pools_mtx;
-static VTAILQ_HEAD(, tcp_pool)	pools = VTAILQ_HEAD_INITIALIZER(pools);
+static struct lock		tcp_pools_mtx;
+static VTAILQ_HEAD(, tcp_pool)	tcp_pools = VTAILQ_HEAD_INITIALIZER(tcp_pools);
 
 /*--------------------------------------------------------------------
  * Waiter-handler
@@ -123,8 +123,9 @@ VTP_Ref(const struct suckaddr *ip4, const struct suckaddr *ip6)
 {
 	struct tcp_pool *tp;
 
-	Lck_Lock(&pools_mtx);
-	VTAILQ_FOREACH(tp, &pools, list) {
+	assert(ip4 != NULL || ip6 != NULL);
+	Lck_Lock(&tcp_pools_mtx);
+	VTAILQ_FOREACH(tp, &tcp_pools, list) {
 		assert(tp->refcnt > 0);
 		if (ip4 == NULL) {
 			if (tp->ip4 != NULL)
@@ -145,10 +146,10 @@ VTP_Ref(const struct suckaddr *ip4, const struct suckaddr *ip6)
 				continue;
 		}
 		tp->refcnt++;
-		Lck_Unlock(&pools_mtx);
+		Lck_Unlock(&tcp_pools_mtx);
 		return (tp);
 	}
-	Lck_Unlock(&pools_mtx);
+	Lck_Unlock(&tcp_pools_mtx);
 
 	ALLOC_OBJ(tp, TCP_POOL_MAGIC);
 	AN(tp);
@@ -157,13 +158,13 @@ VTP_Ref(const struct suckaddr *ip4, const struct suckaddr *ip6)
 	if (ip6 != NULL)
 		tp->ip6 = VSA_Clone(ip6);
 	tp->refcnt = 1;
-	Lck_New(&tp->mtx, lck_backend_tcp);
+	Lck_New(&tp->mtx, lck_tcp_pool);
 	VTAILQ_INIT(&tp->connlist);
 	VTAILQ_INIT(&tp->killlist);
 
-	Lck_Lock(&pools_mtx);
-	VTAILQ_INSERT_HEAD(&pools, tp, list);
-	Lck_Unlock(&pools_mtx);
+	Lck_Lock(&tcp_pools_mtx);
+	VTAILQ_INSERT_HEAD(&tcp_pools, tp, list);
+	Lck_Unlock(&tcp_pools_mtx);
 
 	return (tp);
 }
@@ -177,10 +178,10 @@ VTP_AddRef(struct tcp_pool *tp)
 {
 	CHECK_OBJ_NOTNULL(tp, TCP_POOL_MAGIC);
 
-	Lck_Lock(&pools_mtx);
+	Lck_Lock(&tcp_pools_mtx);
 	assert(tp->refcnt > 0);
 	tp->refcnt++;
-	Lck_Unlock(&pools_mtx);
+	Lck_Unlock(&tcp_pools_mtx);
 }
 
 /*--------------------------------------------------------------------
@@ -195,15 +196,15 @@ VTP_Rel(struct tcp_pool **tpp)
 
 	TAKE_OBJ_NOTNULL(tp, tpp, TCP_POOL_MAGIC);
 
-	Lck_Lock(&pools_mtx);
+	Lck_Lock(&tcp_pools_mtx);
 	assert(tp->refcnt > 0);
 	if (--tp->refcnt > 0) {
-		Lck_Unlock(&pools_mtx);
+		Lck_Unlock(&tcp_pools_mtx);
 		return;
 	}
 	AZ(tp->n_used);
-	VTAILQ_REMOVE(&pools, tp, list);
-	Lck_Unlock(&pools_mtx);
+	VTAILQ_REMOVE(&tcp_pools, tp, list);
+	Lck_Unlock(&tcp_pools_mtx);
 
 	free(tp->name);
 	free(tp->ip4);
@@ -430,5 +431,5 @@ VTP_Wait(struct worker *wrk, struct vtp *vtp)
 void
 VTP_Init(void)
 {
-	Lck_New(&pools_mtx, lck_backend);
+	Lck_New(&tcp_pools_mtx, lck_tcp_pool);
 }
diff --git a/include/tbl/locks.h b/include/tbl/locks.h
index a89b0b4..cf2a6ed 100644
--- a/include/tbl/locks.h
+++ b/include/tbl/locks.h
@@ -30,7 +30,6 @@
 /*lint -save -e525 -e539 */
 
 LOCK(backend)
-LOCK(backend_tcp)
 LOCK(ban)
 LOCK(busyobj)
 LOCK(cli)
@@ -41,6 +40,7 @@ LOCK(mempool)
 LOCK(objhdr)
 LOCK(pipestat)
 LOCK(sess)
+LOCK(tcp_pool)
 LOCK(vbe)
 LOCK(vcapace)
 LOCK(vcl)


More information about the varnish-commit mailing list