[master] 0664f1dac Give TCP Pools a panic function.

Poul-Henning Kamp phk at FreeBSD.org
Tue Jan 5 11:39:07 UTC 2021


commit 0664f1dacd0becce79af89fb00a1297121b70326
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Jan 5 11:22:44 2021 +0000

    Give TCP Pools a panic function.

diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 2fe784892..732613d6a 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -464,11 +464,7 @@ vbe_panic(const struct director *d, struct vsb *vsb)
 	CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
 	CAST_OBJ_NOTNULL(bp, d->priv, BACKEND_MAGIC);
 
-	if (bp->ipv4_addr != NULL)
-		VSB_printf(vsb, "ipv4 = %s,\n", bp->ipv4_addr);
-	if (bp->ipv6_addr != NULL)
-		VSB_printf(vsb, "ipv6 = %s,\n", bp->ipv6_addr);
-	VSB_printf(vsb, "port = %s,\n", bp->port);
+	VTP_panic(vsb, bp->tcp_pool);
 	VSB_printf(vsb, "hosthdr = %s,\n", bp->hosthdr);
 	VSB_printf(vsb, "n_conn = %u,\n", bp->n_conn);
 }
diff --git a/bin/varnishd/cache/cache_tcp_pool.c b/bin/varnishd/cache/cache_tcp_pool.c
index d4451e5b7..66bdce803 100644
--- a/bin/varnishd/cache/cache_tcp_pool.c
+++ b/bin/varnishd/cache/cache_tcp_pool.c
@@ -816,6 +816,33 @@ VTP_getip(struct pfd *pfd)
 
 /*--------------------------------------------------------------------*/
 
+void
+VTP_panic(struct vsb *vsb, struct tcp_pool *tp)
+{
+	char h[VTCP_ADDRBUFSIZE];
+	char p[VTCP_PORTBUFSIZE];
+
+	if (PAN_dump_struct(vsb, tp, TCP_POOL_MAGIC, "tcp_pool"))
+		return;
+	VSB_printf(vsb, "id = 0x%jx,\n", tp->cp->id);
+	if (tp->uds)
+		VSB_printf(vsb, "uds = %s,\n", tp->uds);
+	if (tp->ip4 && VSA_Sane(tp->ip4)) {
+		VTCP_name(tp->ip4, h, sizeof h, p, sizeof p);
+		VSB_printf(vsb, "ipv4 = %s, ", h);
+		VSB_printf(vsb, "port = %s,\n", p);
+	}
+	if (tp->ip6 && VSA_Sane(tp->ip6)) {
+		VTCP_name(tp->ip4, h, sizeof h, p, sizeof p);
+		VSB_printf(vsb, "ipv6 = %s, ", h);
+		VSB_printf(vsb, "port = %s,\n", p);
+	}
+	VSB_indent(vsb, -2);
+	VSB_cat(vsb, "},\n");
+}
+
+/*--------------------------------------------------------------------*/
+
 void
 VTP_Init(void)
 {
diff --git a/bin/varnishd/cache/cache_tcp_pool.h b/bin/varnishd/cache/cache_tcp_pool.h
index 11c7ed211..4d62da5e5 100644
--- a/bin/varnishd/cache/cache_tcp_pool.h
+++ b/bin/varnishd/cache/cache_tcp_pool.h
@@ -103,5 +103,7 @@ int VTP_Wait(struct worker *, struct pfd *, vtim_real tmo);
 	 * function before attempting to receive on the connection.
 	 */
 
+void VTP_panic(struct vsb *, struct tcp_pool *);
+
 const struct suckaddr *VTP_getip(struct pfd *);
 


More information about the varnish-commit mailing list