[master] 355bf7e Refine the VRT_VSM_Cluster prototypes.
Poul-Henning Kamp
phk at FreeBSD.org
Sun Jan 7 20:15:12 UTC 2018
commit 355bf7e7a34fc36b23176d607e68615530800279
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Sat Jan 6 10:12:28 2018 +0000
Refine the VRT_VSM_Cluster prototypes.
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index e8e212c..f8192c1 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -625,11 +625,23 @@ VRT_purge(VRT_CTX, double ttl, double grace, double keep)
/*--------------------------------------------------------------------
*/
-struct vsm_cluster *
-VRT_VSM_Cluster(size_t sz)
+struct vsm_cluster * v_matchproto_()
+VRT_VSM_Cluster_New(VRT_CTX, size_t sz)
{
+
+ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
AN(sz);
- return ((void*)VRT_VSM_Cluster);
+ return ((void*)VRT_VSM_Cluster_New);
+}
+
+void v_matchproto_()
+VRT_VSM_Cluster_Destroy(VRT_CTX, struct vsm_cluster **vcp)
+{
+
+ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
+ AN(vcp);
+ AN(*vcp);
+ *vcp = NULL;
}
/*--------------------------------------------------------------------
diff --git a/include/vrt.h b/include/vrt.h
index ff70504..0a66893 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -394,7 +394,8 @@ void VRT_delete_backend(VRT_CTX, struct director **);
int VRT_backend_healthy(VRT_CTX, struct director *);
/* VSM related */
-struct vsm_cluster *VRT_VSM_Cluster(size_t);
+struct vsm_cluster *VRT_VSM_Cluster_New(VRT_CTX, size_t);
+void VRT_VSM_Cluster_Destroy(VRT_CTX, struct vsm_cluster **);
/* cache_director.c */
int VRT_Healthy(VRT_CTX, VCL_BACKEND);
diff --git a/lib/libvcc/vcc_backend.c b/lib/libvcc/vcc_backend.c
index 4b81bf2..52f72ec 100644
--- a/lib/libvcc/vcc_backend.c
+++ b/lib/libvcc/vcc_backend.c
@@ -449,7 +449,7 @@ vcc_ParseHostDef(struct vcc *tl, const struct token *t_be, const char *vgcname)
ifp = New_IniFin(tl);
VSB_printf(ifp->ini,
- "\t%s =\n\t VRT_new_backend_clustered(ctx, vc,\n"
+ "\t%s =\n\t VRT_new_backend_clustered(ctx, vsc_cluster,\n"
"\t\t&vgc_dir_priv_%s);",
vgcname, vgcname);
}
@@ -500,10 +500,10 @@ vcc_Backend_Init(struct vcc *tl)
{
struct inifin *ifp;
+ Fh(tl, 0, "\nstatic struct vsm_cluster *vsc_cluster;\n");
ifp = New_IniFin(tl);
- VSB_printf(ifp->ini, "\tstruct vsm_cluster *vc;\n");
- VSB_printf(ifp->ini, "\n");
- VSB_printf(ifp->ini,
- "\tvc = VRT_VSM_Cluster(ndirector * VRT_backend_vsm_need(ctx));\n");
- VSB_printf(ifp->ini, "\tif (vc == 0)\n\t\treturn(1);");
+ VSB_printf(ifp->ini, "\tvsc_cluster = VRT_VSM_Cluster_New(ctx,\n"
+ "\t ndirector * VRT_backend_vsm_need(ctx));\n");
+ VSB_printf(ifp->ini, "\tif (vsc_cluster == 0)\n\t\treturn(1);");
+ VSB_printf(ifp->fin, "\tVRT_VSM_Cluster_Destroy(ctx, &vsc_cluster);");
}
diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c
index a079aee..0e84062 100644
--- a/lib/libvcc/vcc_compile.c
+++ b/lib/libvcc/vcc_compile.c
@@ -560,6 +560,9 @@ vcc_CompileSource(struct vcc *tl, struct source *sp)
struct vsb *vsb;
struct inifin *ifp;
+ Fh(tl, 0, "/* ---===### VCC generated .h code ###===---*/\n");
+ Fc(tl, 0, "\n/* ---===### VCC generated .c code ###===---*/\n");
+
vcc_Expr_Init(tl);
vcc_Backend_Init(tl);
@@ -581,8 +584,6 @@ vcc_CompileSource(struct vcc *tl, struct source *sp)
REPLACE(sym->rname, v->rname);
}
- Fh(tl, 0, "/* ---===### VCC generated .h code ###===---*/\n");
- Fc(tl, 0, "\n/* ---===### VCC generated .c code ###===---*/\n");
Fh(tl, 0, "\nextern const struct VCL_conf VCL_conf;\n");
/* Register and lex the main source */
diff --git a/lib/libvcc/vsctool.py b/lib/libvcc/vsctool.py
index e368cf9..1227b7c 100644
--- a/lib/libvcc/vsctool.py
+++ b/lib/libvcc/vsctool.py
@@ -199,8 +199,8 @@ class vscset(object):
fo.write("\tva_start(ap, fmt);\n")
fo.write("\tretval = VRT_VSC_Alloc")
fo.write("(vc, sg, vsc_" + self.name + "_name, ")
- fo.write("sizeof(" + self.struct + "),\n\t ")
- fo.write("vsc_" + self.name + "_json, ")
+ fo.write("VSC_" + self.name + "_size,\n")
+ fo.write("\t vsc_" + self.name + "_json, ")
fo.write("sizeof vsc_" + self.name + "_json, fmt, ap);\n")
fo.write("\tva_end(ap);\n")
fo.write("\treturn(retval);\n")
More information about the varnish-commit
mailing list