[master] 2c128ca Move the panic-dump of VCL's to cache_vcl.c so cache_panic.c doesn't need to know what's inside.

Poul-Henning Kamp phk at FreeBSD.org
Wed Jun 17 11:39:04 CEST 2015


commit 2c128ca1917f434e32008c350a158ab49517f958
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Jun 17 08:34:29 2015 +0000

    Move the panic-dump of VCL's to cache_vcl.c so cache_panic.c doesn't
    need to know what's inside.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index a29d998..3492ae5 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -1066,6 +1066,7 @@ void VRY_Finish(struct req *req, enum vry_finish_flag);
 
 /* cache_vcl.c */
 void VCL_Init(void);
+void VCL_Panic(struct vsb *, const struct VCL_conf *);
 void VCL_Refresh(struct VCL_conf **vcc);
 void VCL_Ref(struct VCL_conf *vcc);
 void VCL_Rel(struct VCL_conf **vcc);
diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index 6f59a5e..3755508 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -45,7 +45,6 @@
 
 #include "cache_backend.h"
 #include "storage/storage.h"
-#include "vcl.h"
 #include "vcli_priv.h"
 
 /*
@@ -257,22 +256,6 @@ pan_objcore(const char *typ, const struct objcore *oc)
 /*--------------------------------------------------------------------*/
 
 static void
-pan_vcl(const struct VCL_conf *vcl)
-{
-	int i;
-
-	VSB_printf(pan_vsp, "  vcl = {\n");
-	VSB_printf(pan_vsp, "    srcname = {\n");
-	for (i = 0; i < vcl->nsrc; ++i)
-		VSB_printf(pan_vsp, "      \"%s\",\n", vcl->srcname[i]);
-	VSB_printf(pan_vsp, "    },\n");
-	VSB_printf(pan_vsp, "  },\n");
-}
-
-
-/*--------------------------------------------------------------------*/
-
-static void
 pan_wrk(const struct worker *wrk)
 {
 	const char *hand;
@@ -406,8 +389,7 @@ pan_req(const struct req *req)
 	if (req->resp->ws != NULL)
 		pan_http("resp", req->resp, 2);
 
-	if (VALID_OBJ(req->vcl, VCL_CONF_MAGIC))
-		pan_vcl(req->vcl);
+	VCL_Panic(pan_vsp, req->vcl);
 
 	if (req->objcore != NULL) {
 		pan_objcore("REQ", req->objcore);
diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index bea6a90..db5aa2d 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -66,6 +66,24 @@ static struct vcl		*vcl_active; /* protected by vcl_mtx */
 
 /*--------------------------------------------------------------------*/
 
+void
+VCL_Panic(struct vsb *vsb, const struct VCL_conf *vcl)
+{
+	int i;
+
+	AN(vsb);
+	if (vcl == NULL)
+		return;
+	VSB_printf(vsb, "  vcl = {\n");
+	VSB_printf(vsb, "    srcname = {\n");
+	for (i = 0; i < vcl->nsrc; ++i)
+		VSB_printf(vsb, "      \"%s\",\n", vcl->srcname[i]);
+	VSB_printf(vsb, "    },\n");
+	VSB_printf(vsb, "  },\n");
+}
+
+/*--------------------------------------------------------------------*/
+
 const char *
 VCL_Return_Name(unsigned r)
 {



More information about the varnish-commit mailing list