[master] 860d7de Push the req->busyobj change all the way up through getfd.

Poul-Henning Kamp phk at varnish-cache.org
Mon Apr 29 17:36:30 CEST 2013


commit 860d7de5ded545042fb5a64ef1f8986a05421247
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Apr 29 15:36:03 2013 +0000

    Push the req->busyobj change all the way up through getfd.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index e77ebc8..ccbd56c 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -734,7 +734,7 @@ void VBE_UseHealth(const struct director *vdi);
 void VBE_DiscardHealth(const struct director *vdi);
 
 
-struct vbc *VDI_GetFd(const struct director *, struct req *);
+struct vbc *VDI_GetFd(const struct director *, struct busyobj *);
 int VDI_Healthy(const struct director *, const uint8_t *digest);
 void VDI_CloseFd(struct vbc **vbp);
 void VDI_RecycleFd(struct vbc **vbp);
diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 693f631..f3ae536 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -455,20 +455,20 @@ VBE_DiscardHealth(const struct director *vdi)
  */
 
 static struct vbc * __match_proto__(vdi_getfd_f)
-vdi_simple_getfd(const struct director *d, struct req *req)
+vdi_simple_getfd(const struct director *d, struct busyobj *bo)
 {
 	struct vdi_simple *vs;
 	struct vbc *vc;
 
-	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
 	CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC);
-	vc = vbe_GetVbe(req->busyobj, vs);
+	vc = vbe_GetVbe(bo, vs);
 	if (vc != NULL) {
 		FIND_TMO(first_byte_timeout,
-		    vc->first_byte_timeout, req->busyobj, vs->vrt);
+		    vc->first_byte_timeout, bo, vs->vrt);
 		FIND_TMO(between_bytes_timeout,
-		    vc->between_bytes_timeout, req->busyobj, vs->vrt);
+		    vc->between_bytes_timeout, bo, vs->vrt);
 	}
 	return (vc);
 }
diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h
index 13d452e..97f7898 100644
--- a/bin/varnishd/cache/cache_backend.h
+++ b/bin/varnishd/cache/cache_backend.h
@@ -75,7 +75,7 @@ struct vrt_backend_probe;
  * backends to use.
  */
 
-typedef struct vbc *vdi_getfd_f(const struct director *, struct req *);
+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 *, const uint8_t *digest);
 
diff --git a/bin/varnishd/cache/cache_dir.c b/bin/varnishd/cache/cache_dir.c
index f4a21c9..366b864 100644
--- a/bin/varnishd/cache/cache_dir.c
+++ b/bin/varnishd/cache/cache_dir.c
@@ -101,17 +101,17 @@ VDI_RecycleFd(struct vbc **vbp)
 /* Get a connection --------------------------------------------------*/
 
 struct vbc *
-VDI_GetFd(const struct director *d, struct req *req)
+VDI_GetFd(const struct director *d, struct busyobj *bo)
 {
 	struct vbc *vc;
 
-	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	if (d == NULL)
-		d = req->director;
+		d = bo->director;
 	CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
-	vc = d->getfd(d, req);
+	vc = d->getfd(d, bo);
 	if (vc != NULL)
-		vc->vsl = req->busyobj->vsl;
+		vc->vsl = bo->vsl;
 	return (vc);
 }
 
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index f4befdf..951e367 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -383,7 +383,7 @@ FetchHdr(struct req *req, int need_host_hdr, int sendbody)
 
 	hp = bo->bereq;
 
-	bo->vbc = VDI_GetFd(NULL, req);
+	bo->vbc = VDI_GetFd(NULL, bo);
 	if (bo->vbc == NULL) {
 		VSLb(req->vsl, SLT_FetchError, "no backend connection");
 		return (-1);
diff --git a/bin/varnishd/cache/cache_pipe.c b/bin/varnishd/cache/cache_pipe.c
index 36c48ad..e76151b 100644
--- a/bin/varnishd/cache/cache_pipe.c
+++ b/bin/varnishd/cache/cache_pipe.c
@@ -75,7 +75,7 @@ PipeRequest(struct req *req)
 	bo = req->busyobj;
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 
-	vc = VDI_GetFd(NULL, req);
+	vc = VDI_GetFd(NULL, bo);
 	if (vc == NULL)
 		return;
 	bo->vbc = vc;		/* For panic dumping */
diff --git a/lib/libvmod_directors/fall_back.c b/lib/libvmod_directors/fall_back.c
index af25ac3..7907700 100644
--- a/lib/libvmod_directors/fall_back.c
+++ b/lib/libvmod_directors/fall_back.c
@@ -54,7 +54,7 @@ vmod_rr_healthy(const struct director *dir, const uint8_t *digest)
 }
 
 static struct vbc * __match_proto__(vdi_getfd_f)
-vmod_rr_getfd(const struct director *dir, struct req *req)
+vmod_rr_getfd(const struct director *dir, struct busyobj *bo)
 {
 	struct vmod_directors_fallback *rr;
 	unsigned u;
@@ -65,13 +65,13 @@ vmod_rr_getfd(const struct director *dir, struct req *req)
 	for (u = 0; u < rr->vd->n_backend; u++) {
 		be = rr->vd->backend[u];
 		CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC);
-		if (be->healthy(be, req->digest))
+		if (be->healthy(be, bo->digest))
 			break;
 	}
 	vdir_unlock(rr->vd);
 	if (u == rr->vd->n_backend || be == NULL)
 		return (NULL);
-	return (be->getfd(be, req));
+	return (be->getfd(be, bo));
 }
 
 VCL_VOID __match_proto__()
diff --git a/lib/libvmod_directors/hash.c b/lib/libvmod_directors/hash.c
index ea011a3..ac9bd41 100644
--- a/lib/libvmod_directors/hash.c
+++ b/lib/libvmod_directors/hash.c
@@ -118,6 +118,6 @@ vmod_hash_backend(struct req *req, struct vmod_directors_hash *rr, const char *a
 
 	r = vbe32dec(sha256);
 	r = scalbn(r, -32);
-	be = vdir_pick_be(rr->vd, req, r, rr->nloops);
+	be = vdir_pick_be(rr->vd, req->busyobj, r, rr->nloops);
 	return (be);
 }
diff --git a/lib/libvmod_directors/random.c b/lib/libvmod_directors/random.c
index d12b5b2..d51c170 100644
--- a/lib/libvmod_directors/random.c
+++ b/lib/libvmod_directors/random.c
@@ -59,7 +59,7 @@ vmod_rr_healthy(const struct director *dir, const uint8_t *digest)
 }
 
 static struct vbc * __match_proto__(vdi_getfd_f)
-vmod_rr_getfd(const struct director *dir, struct req *req)
+vmod_rr_getfd(const struct director *dir, struct busyobj *bo)
 {
 	struct vmod_directors_random *rr;
 	VCL_BACKEND be;
@@ -67,10 +67,10 @@ vmod_rr_getfd(const struct director *dir, struct req *req)
 
 	CAST_OBJ_NOTNULL(rr, dir->priv, VMOD_DIRECTORS_RANDOM_MAGIC);
 	r = scalbn(random(), -31);
-	be = vdir_pick_be(rr->vd, req, r, rr->nloops);
+	be = vdir_pick_be(rr->vd, bo, r, rr->nloops);
 	if (be == NULL)
 		return (NULL);
-	return (be->getfd(be, req));
+	return (be->getfd(be, bo));
 }
 
 VCL_VOID __match_proto__()
diff --git a/lib/libvmod_directors/round_robin.c b/lib/libvmod_directors/round_robin.c
index 35e2454..fb4ba92 100644
--- a/lib/libvmod_directors/round_robin.c
+++ b/lib/libvmod_directors/round_robin.c
@@ -55,7 +55,7 @@ vmod_rr_healthy(const struct director *dir, const uint8_t *digest)
 }
 
 static struct vbc * __match_proto__(vdi_getfd_f)
-vmod_rr_getfd(const struct director *dir, struct req *req)
+vmod_rr_getfd(const struct director *dir, struct busyobj *bo)
 {
 	struct vmod_directors_round_robin *rr;
 	unsigned u;
@@ -68,13 +68,13 @@ vmod_rr_getfd(const struct director *dir, struct req *req)
 		be = rr->vd->backend[rr->nxt];
 		rr->nxt++;
 		CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC);
-		if (be->healthy(be, req->digest))
+		if (be->healthy(be, bo->digest))
 			break;
 	}
 	vdir_unlock(rr->vd);
 	if (u == rr->vd->n_backend || be == NULL)
 		return (NULL);
-	return (be->getfd(be, req));
+	return (be->getfd(be, bo));
 }
 
 VCL_VOID __match_proto__()
diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c
index c921cf0..62b0033 100644
--- a/lib/libvmod_directors/vdir.c
+++ b/lib/libvmod_directors/vdir.c
@@ -169,7 +169,8 @@ vdir_pick_by_weight(const struct vdir *vd, double w,
 }
 
 VCL_BACKEND
-vdir_pick_be(struct vdir *vd, const struct req *req, double w, unsigned nloops)
+vdir_pick_be(struct vdir *vd, const struct busyobj *bo, double w,
+    unsigned nloops)
 {
 	struct vbitmap *vbm = NULL;
 	unsigned u, v, l;
@@ -185,7 +186,7 @@ vdir_pick_be(struct vdir *vd, const struct req *req, 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, req->digest))
+		if (be->healthy(be, bo->digest))
 			break;
 		if (l == 0) {
 			vbm = vd->vbm;
diff --git a/lib/libvmod_directors/vdir.h b/lib/libvmod_directors/vdir.h
index 1bd8648..fa7a458 100644
--- a/lib/libvmod_directors/vdir.h
+++ b/lib/libvmod_directors/vdir.h
@@ -48,5 +48,5 @@ 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, const uint8_t *digest);
-VCL_BACKEND vdir_pick_be(struct vdir *vd, const struct req *req, double w,
+VCL_BACKEND vdir_pick_be(struct vdir *vd, const struct busyobj *, double w,
     unsigned nloops);



More information about the varnish-commit mailing list