[master] 6327bfb Remove a unnecessary level of indirection when creating/destroying VCL created simple directors.

Poul-Henning Kamp phk at varnish-cache.org
Tue Sep 10 09:44:41 CEST 2013


commit 6327bfbfeb6284ade279808dd0160d9ea517d26b
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Sep 10 07:44:09 2013 +0000

    Remove a unnecessary level of indirection when creating/destroying
    VCL created simple directors.

diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 3c3e460..a7dfd2a 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -402,11 +402,14 @@ vdi_simple_healthy(const struct director *d, double *changed)
 	return (VBE_Healthy(be, changed));
 }
 
-static void
-vdi_simple_fini(const struct director *d)
+/*--------------------------------------------------------------------*/
+
+void
+VRT_fini_dir(struct cli *cli, struct director *d)
 {
 	struct vdi_simple *vs;
 
+	(void)cli;
 	ASSERT_CLI();
 	CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
 	CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC);
@@ -415,11 +418,11 @@ vdi_simple_fini(const struct director *d)
 	free(vs->dir.vcl_name);
 	vs->dir.magic = 0;
 	FREE_OBJ(vs);
+	d->priv = NULL;
 }
 
 void
-VRT_init_dir_simple(struct cli *cli, struct director **bp, int idx,
-    const void *priv)
+VRT_init_dir(struct cli *cli, struct director **bp, int idx, const void *priv)
 {
 	const struct vrt_backend *t;
 	struct vdi_simple *vs;
@@ -435,7 +438,6 @@ VRT_init_dir_simple(struct cli *cli, struct director **bp, int idx,
 	vs->dir.name = "simple";
 	REPLACE(vs->dir.vcl_name, t->vcl_name);
 	vs->dir.getfd = vdi_simple_getfd;
-	vs->dir.fini = vdi_simple_fini;
 	vs->dir.healthy = vdi_simple_healthy;
 
 	vs->vrt = t;
diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h
index f3931e9..8ce403d 100644
--- a/bin/varnishd/cache/cache_backend.h
+++ b/bin/varnishd/cache/cache_backend.h
@@ -76,7 +76,6 @@ struct vrt_backend_probe;
  */
 
 typedef struct vbc *vdi_getfd_f(const struct director *, struct busyobj *);
-typedef void vdi_fini_f(const struct director *);
 typedef unsigned vdi_healthy(const struct director *, double *changed);
 
 struct director {
@@ -85,7 +84,6 @@ struct director {
 	const char		*name;
 	char			*vcl_name;
 	vdi_getfd_f		*getfd;
-	vdi_fini_f		*fini;
 	vdi_healthy		*healthy;
 	void			*priv;
 };
@@ -165,7 +163,3 @@ void VBP_Insert(struct backend *b, struct vrt_backend_probe const *p,
 void VBP_Remove(struct backend *b, struct vrt_backend_probe const *p);
 void VBP_Use(const struct backend *b, const struct vrt_backend_probe *p);
 void VBP_Summary(struct cli *cli, const struct vbp_target *vt);
-
-/* Init functions for directors */
-typedef void dir_init_f(struct cli *, struct director **, int , const void*);
-dir_init_f VRT_init_dir_simple;
diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c
index 2d55147..e451bc8 100644
--- a/bin/varnishd/cache/cache_backend_cfg.c
+++ b/bin/varnishd/cache/cache_backend_cfg.c
@@ -239,31 +239,6 @@ VBE_AddBackend(struct cli *cli, const struct vrt_backend *vb)
 	return (b);
 }
 
-/*--------------------------------------------------------------------*/
-
-void
-VRT_init_dir(struct cli *cli, struct director **dir, const char *name,
-    int idx, const void *priv)
-{
-
-	ASSERT_CLI();
-	if (!strcmp(name, "simple"))
-		VRT_init_dir_simple(cli, dir, idx, priv);
-	else
-		INCOMPL();
-}
-
-void
-VRT_fini_dir(struct cli *cli, struct director *b)
-{
-
-	(void)cli;
-	ASSERT_CLI();
-	CHECK_OBJ_NOTNULL(b, DIRECTOR_MAGIC);
-	b->fini(b);
-	b->priv = NULL;
-}
-
 /*---------------------------------------------------------------------
  * String to admin_health
  */
diff --git a/include/vrt.h b/include/vrt.h
index 1d079fc..d229655 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -222,8 +222,7 @@ void VRT_Rollback(const struct vrt_ctx *);
 void VRT_synth_page(const struct vrt_ctx *, unsigned flags, const char *, ...);
 
 /* Backend related */
-void VRT_init_dir(struct cli *, struct director **, const char *name,
-    int idx, const void *priv);
+void VRT_init_dir(struct cli *, struct director **, int idx, const void *priv);
 void VRT_fini_dir(struct cli *, struct director *);
 
 /* VMOD/Modules related */
diff --git a/lib/libvcl/vcc_backend.c b/lib/libvcl/vcc_backend.c
index b013400..1f95772 100644
--- a/lib/libvcl/vcc_backend.c
+++ b/lib/libvcl/vcc_backend.c
@@ -444,7 +444,7 @@ vcc_ParseHostDef(struct vcc *tl, int serial, const char *vgcname)
 	Fh(tl, 0, "%s", VSB_data(vsb));
 	VSB_delete(vsb);
 
-	Fi(tl, 0, "\tVRT_init_dir(cli, VCL_conf.director, \"simple\",\n"
+	Fi(tl, 0, "\tVRT_init_dir(cli, VCL_conf.director,\n"
 	    "\t    VGC_backend_%s, &vgc_dir_priv_%s);\n", vgcname, vgcname);
 	Ff(tl, 0, "\tVRT_fini_dir(cli, VGCDIR(%s));\n", vgcname);
 	tl->ndirector++;



More information about the varnish-commit mailing list