[master] 9e6f88d Add the name of the built-in directors during init

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Tue Aug 11 09:52:01 CEST 2015


commit 9e6f88dede2eec3d366f52ea36076557581b9854
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Tue Aug 11 09:46:41 2015 +0200

    Add the name of the built-in directors during init

diff --git a/lib/libvmod_directors/fall_back.c b/lib/libvmod_directors/fall_back.c
index 77ec45c..e73b1cf 100644
--- a/lib/libvmod_directors/fall_back.c
+++ b/lib/libvmod_directors/fall_back.c
@@ -91,7 +91,7 @@ vmod_fallback__init(VRT_CTX,
 	ALLOC_OBJ(rr, VMOD_DIRECTORS_FALLBACK_MAGIC);
 	AN(rr);
 	*rrp = rr;
-	vdir_new(&rr->vd, vcl_name, vmod_fallback_healthy,
+	vdir_new(&rr->vd, "fallback", vcl_name, vmod_fallback_healthy,
 	    vmod_fallback_resolve, rr);
 }
 
diff --git a/lib/libvmod_directors/hash.c b/lib/libvmod_directors/hash.c
index c3def17..3029c7b 100644
--- a/lib/libvmod_directors/hash.c
+++ b/lib/libvmod_directors/hash.c
@@ -64,7 +64,7 @@ vmod_hash__init(VRT_CTX, struct vmod_directors_hash **rrp,
 	rr->vbm = vbit_init(8);
 	AN(rr->vbm);
 	*rrp = rr;
-	vdir_new(&rr->vd, vcl_name, NULL, NULL, rr);
+	vdir_new(&rr->vd, "hash", vcl_name, NULL, NULL, rr);
 }
 
 VCL_VOID __match_proto__()
diff --git a/lib/libvmod_directors/random.c b/lib/libvmod_directors/random.c
index a0612f3..2f29887 100644
--- a/lib/libvmod_directors/random.c
+++ b/lib/libvmod_directors/random.c
@@ -87,8 +87,8 @@ vmod_random__init(VRT_CTX, struct vmod_directors_random **rrp,
 	ALLOC_OBJ(rr, VMOD_DIRECTORS_RANDOM_MAGIC);
 	AN(rr);
 	*rrp = rr;
-	vdir_new(&rr->vd, vcl_name, vmod_random_healthy, vmod_random_resolve,
-	    rr);
+	vdir_new(&rr->vd, "random", vcl_name, vmod_random_healthy,
+	    vmod_random_resolve, rr);
 }
 
 VCL_VOID __match_proto__()
diff --git a/lib/libvmod_directors/round_robin.c b/lib/libvmod_directors/round_robin.c
index be92545..b2acf49 100644
--- a/lib/libvmod_directors/round_robin.c
+++ b/lib/libvmod_directors/round_robin.c
@@ -94,7 +94,8 @@ vmod_round_robin__init(VRT_CTX,
 	ALLOC_OBJ(rr, VMOD_DIRECTORS_ROUND_ROBIN_MAGIC);
 	AN(rr);
 	*rrp = rr;
-	vdir_new(&rr->vd, vcl_name, vmod_rr_healthy, vmod_rr_resolve, rr);
+	vdir_new(&rr->vd, "round-robin", vcl_name, vmod_rr_healthy,
+	    vmod_rr_resolve, rr);
 }
 
 VCL_VOID __match_proto__()
diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c
index 938d6de..411df34 100644
--- a/lib/libvmod_directors/vdir.c
+++ b/lib/libvmod_directors/vdir.c
@@ -51,11 +51,12 @@ vdir_expand(struct vdir *vd, unsigned n)
 }
 
 void
-vdir_new(struct vdir **vdp, const char *vcl_name, vdi_healthy_f *healthy,
-    vdi_resolve_f *resolve, void *priv)
+vdir_new(struct vdir **vdp, const char *name, const char *vcl_name,
+    vdi_healthy_f *healthy, vdi_resolve_f *resolve, void *priv)
 {
 	struct vdir *vd;
 
+	AN(name);
 	AN(vcl_name);
 	AN(vdp);
 	AZ(*vdp);
@@ -66,6 +67,7 @@ vdir_new(struct vdir **vdp, const char *vcl_name, vdi_healthy_f *healthy,
 
 	ALLOC_OBJ(vd->dir, DIRECTOR_MAGIC);
 	AN(vd->dir);
+	vd->dir->name = name;
 	REPLACE(vd->dir->vcl_name, vcl_name);
 	vd->dir->priv = priv;
 	vd->dir->healthy = healthy;
diff --git a/lib/libvmod_directors/vdir.h b/lib/libvmod_directors/vdir.h
index 9214911..2e1cfe1 100644
--- a/lib/libvmod_directors/vdir.h
+++ b/lib/libvmod_directors/vdir.h
@@ -41,8 +41,8 @@ struct vdir {
 	struct vbitmap				*vbm;
 };
 
-void vdir_new(struct vdir **vdp, const char *vcl_name, vdi_healthy_f *healthy,
-    vdi_resolve_f *resolve, void *priv);
+void vdir_new(struct vdir **vdp, const char *name, const char *vcl_name,
+    vdi_healthy_f *healthy, vdi_resolve_f *resolve, void *priv);
 void vdir_delete(struct vdir **vdp);
 void vdir_lock(struct vdir *vd);
 void vdir_unlock(struct vdir *vd);



More information about the varnish-commit mailing list