[master] 418cea5 Add busyobj as argument to vdir->healthy()

Poul-Henning Kamp phk at FreeBSD.org
Tue Oct 28 12:42:18 CET 2014


commit 418cea5d6c32f14aaa16a7d0b58b8e8a6e287bb9
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Oct 28 07:21:23 2014 +0000

    Add busyobj as argument to vdir->healthy()

diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 4ddc3ca..0befb29 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -370,12 +370,14 @@ vbe_dir_getfd(const struct director *d, struct busyobj *bo)
 }
 
 static unsigned __match_proto__(vdi_healthy_f)
-vbe_dir_healthy(const struct director *d, double *changed)
+vbe_dir_healthy(const struct director *d, const struct busyobj *bo,
+    double *changed)
 {
 	struct vbe_dir *vs;
 	struct backend *be;
 
 	CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
+	CHECK_OBJ_ORNULL(bo, BUSYOBJ_MAGIC);
 	CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC);
 	be = vs->backend;
 	CHECK_OBJ_NOTNULL(be, BACKEND_MAGIC);
diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c
index c79b3a8..0df939e 100644
--- a/bin/varnishd/cache/cache_director.c
+++ b/bin/varnishd/cache/cache_director.c
@@ -145,12 +145,12 @@ VDI_GetFd(const struct director *d, struct worker *wrk, struct busyobj *bo)
  */
 
 int
-VDI_Healthy(const struct director *d)
+VDI_Healthy(const struct director *d, const struct busyobj *bo)
 {
 
 	CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
 	AN(d->healthy);
-	return (d->healthy(d, NULL));
+	return (d->healthy(d, bo, NULL));
 }
 
 /* Get suckaddr ------------------------------------------------------*/
diff --git a/bin/varnishd/cache/cache_director.h b/bin/varnishd/cache/cache_director.h
index cef951d..e904686 100644
--- a/bin/varnishd/cache/cache_director.h
+++ b/bin/varnishd/cache/cache_director.h
@@ -43,7 +43,8 @@
  */
 
 typedef int vdi_getfd_f(const struct director *, struct busyobj *);
-typedef unsigned vdi_healthy_f(const struct director *, double *changed);
+typedef unsigned vdi_healthy_f(const struct director *, const struct busyobj *,
+    double *changed);
 typedef const struct director *vdi_resolve_f(const struct director *,
     struct worker *, struct busyobj *);
 typedef int vdi_gethdrs_f(const struct director *, struct worker *,
@@ -77,7 +78,7 @@ int VDI_GetBody(const struct director *d, struct worker *wrk,
 void VDI_Finish(const struct director *d, struct worker *wrk,
     struct busyobj *bo);
 int VDI_GetFd(const struct director *d, struct worker *wrk, struct busyobj *);
-int VDI_Healthy(const struct director *);
+int VDI_Healthy(const struct director *, const struct busyobj *);
 struct suckaddr *VDI_Suckaddr(const struct director *d, struct worker *wrk,
     struct busyobj *bo);
 void VDI_AddHostHeader(struct http *to, const struct vbc *vbc);
diff --git a/lib/libvmod_directors/fall_back.c b/lib/libvmod_directors/fall_back.c
index a3d2a9c..25b05dd 100644
--- a/lib/libvmod_directors/fall_back.c
+++ b/lib/libvmod_directors/fall_back.c
@@ -45,12 +45,13 @@ struct vmod_directors_fallback {
 };
 
 static unsigned __match_proto__(vdi_healthy)
-vmod_fallback_healthy(const struct director *dir, double *changed)
+vmod_fallback_healthy(const struct director *dir, const struct busyobj *bo,
+    double *changed)
 {
 	struct vmod_directors_fallback *rr;
 
 	CAST_OBJ_NOTNULL(rr, dir->priv, VMOD_DIRECTORS_FALLBACK_MAGIC);
-	return (vdir_any_healthy(rr->vd, changed));
+	return (vdir_any_healthy(rr->vd, bo, changed));
 }
 
 static const struct director * __match_proto__(vdi_resolve_f)
@@ -69,7 +70,7 @@ vmod_fallback_resolve(const struct director *dir, struct worker *wrk,
 	for (u = 0; u < rr->vd->n_backend; u++) {
 		be = rr->vd->backend[u];
 		CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC);
-		if (be->healthy(be, NULL))
+		if (be->healthy(be, bo, NULL))
 			break;
 	}
 	vdir_unlock(rr->vd);
diff --git a/lib/libvmod_directors/random.c b/lib/libvmod_directors/random.c
index a693bc6..c368392 100644
--- a/lib/libvmod_directors/random.c
+++ b/lib/libvmod_directors/random.c
@@ -50,12 +50,13 @@ struct vmod_directors_random {
 };
 
 static unsigned __match_proto__(vdi_healthy)
-vmod_random_healthy(const struct director *dir, double *changed)
+vmod_random_healthy(const struct director *dir, const struct busyobj *bo,
+    double *changed)
 {
 	struct vmod_directors_random *rr;
 
 	CAST_OBJ_NOTNULL(rr, dir->priv, VMOD_DIRECTORS_RANDOM_MAGIC);
-	return (vdir_any_healthy(rr->vd, changed));
+	return (vdir_any_healthy(rr->vd, bo, changed));
 }
 
 static const struct director * __match_proto__(vdi_resolve_f)
diff --git a/lib/libvmod_directors/round_robin.c b/lib/libvmod_directors/round_robin.c
index 39f6b3d..26668ec 100644
--- a/lib/libvmod_directors/round_robin.c
+++ b/lib/libvmod_directors/round_robin.c
@@ -46,12 +46,13 @@ struct vmod_directors_round_robin {
 };
 
 static unsigned __match_proto__(vdi_healthy)
-vmod_rr_healthy(const struct director *dir, double *changed)
+vmod_rr_healthy(const struct director *dir, const struct busyobj *bo,
+    double *changed)
 {
 	struct vmod_directors_round_robin *rr;
 
 	CAST_OBJ_NOTNULL(rr, dir->priv, VMOD_DIRECTORS_ROUND_ROBIN_MAGIC);
-	return (vdir_any_healthy(rr->vd, changed));
+	return (vdir_any_healthy(rr->vd, bo, changed));
 }
 
 static const struct director * __match_proto__(vdi_resolve_f)
@@ -72,7 +73,7 @@ vmod_rr_resolve(const struct director *dir, struct worker *wrk,
 		be = rr->vd->backend[rr->nxt];
 		rr->nxt++;
 		CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC);
-		if (be->healthy(be, NULL))
+		if (be->healthy(be, bo, NULL))
 			break;
 	}
 	vdir_unlock(rr->vd);
diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c
index 3488026..0ed64ec 100644
--- a/lib/libvmod_directors/vdir.c
+++ b/lib/libvmod_directors/vdir.c
@@ -129,7 +129,7 @@ vdir_add_backend(struct vdir *vd, VCL_BACKEND be, double weight)
 }
 
 unsigned
-vdir_any_healthy(struct vdir *vd, double *changed)
+vdir_any_healthy(struct vdir *vd, const struct busyobj *bo, double *changed)
 {
 	unsigned retval = 0;
 	VCL_BACKEND be;
@@ -137,13 +137,14 @@ vdir_any_healthy(struct vdir *vd, double *changed)
 	double c;
 
 	CHECK_OBJ_NOTNULL(vd, VDIR_MAGIC);
+	CHECK_OBJ_ORNULL(bo, BUSYOBJ_MAGIC);
 	vdir_lock(vd);
 	if (changed != NULL)
 		*changed = 0;
 	for (u = 0; u < vd->n_backend; u++) {
 		be = vd->backend[u];
 		CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC);
-		retval = be->healthy(be, &c);
+		retval = be->healthy(be, bo, &c);
 		if (changed != NULL && c > *changed)
 			*changed = c;
 		if (retval)
@@ -190,7 +191,7 @@ vdir_pick_be(struct vdir *vd, double w, unsigned nloops)
 		u = vdir_pick_by_weight(vd, w * tw, vbm);
 		be = vd->backend[u];
 		CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC);
-		if (be->healthy(be, NULL))
+		if (be->healthy(be, NULL, NULL))
 			break;
 		if (l == 0) {
 			vbm = vd->vbm;
diff --git a/lib/libvmod_directors/vdir.h b/lib/libvmod_directors/vdir.h
index 5afb754..0d21e2f 100644
--- a/lib/libvmod_directors/vdir.h
+++ b/lib/libvmod_directors/vdir.h
@@ -46,6 +46,7 @@ void vdir_new(struct vdir **vdp, const char *vcl_name, vdi_healthy_f *healthy,
 void vdir_delete(struct vdir **vdp);
 void vdir_lock(struct vdir *vd);
 void vdir_unlock(struct vdir *vd);
-unsigned vdir_add_backend(struct vdir *vd, VCL_BACKEND be, double weight);
-unsigned vdir_any_healthy(struct vdir *vd, double *changed);
-VCL_BACKEND vdir_pick_be(struct vdir *vd, double w, unsigned nloops);
+unsigned vdir_add_backend(struct vdir *, VCL_BACKEND be, double weight);
+unsigned vdir_any_healthy(struct vdir *, const struct busyobj *,
+    double *changed);
+VCL_BACKEND vdir_pick_be(struct vdir *, double w, unsigned nloops);
diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c
index 792f04b..35c417b 100644
--- a/lib/libvmod_std/vmod_std.c
+++ b/lib/libvmod_std/vmod_std.c
@@ -193,7 +193,7 @@ vmod_healthy(VRT_CTX, VCL_BACKEND be)
 	if (be == NULL)
 		return (0);
 	CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC);
-	return (VDI_Healthy(be));
+	return (VDI_Healthy(be, ctx->bo));
 }
 
 VCL_INT __match_proto__(td_std_port)



More information about the varnish-commit mailing list