Commit 860d7de5 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

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

parent 8b86482c
...@@ -734,7 +734,7 @@ void VBE_UseHealth(const struct director *vdi); ...@@ -734,7 +734,7 @@ void VBE_UseHealth(const struct director *vdi);
void VBE_DiscardHealth(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); int VDI_Healthy(const struct director *, const uint8_t *digest);
void VDI_CloseFd(struct vbc **vbp); void VDI_CloseFd(struct vbc **vbp);
void VDI_RecycleFd(struct vbc **vbp); void VDI_RecycleFd(struct vbc **vbp);
......
...@@ -455,20 +455,20 @@ VBE_DiscardHealth(const struct director *vdi) ...@@ -455,20 +455,20 @@ VBE_DiscardHealth(const struct director *vdi)
*/ */
static struct vbc * __match_proto__(vdi_getfd_f) 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 vdi_simple *vs;
struct vbc *vc; struct vbc *vc;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC); CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC);
vc = vbe_GetVbe(req->busyobj, vs); vc = vbe_GetVbe(bo, vs);
if (vc != NULL) { if (vc != NULL) {
FIND_TMO(first_byte_timeout, 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, FIND_TMO(between_bytes_timeout,
vc->between_bytes_timeout, req->busyobj, vs->vrt); vc->between_bytes_timeout, bo, vs->vrt);
} }
return (vc); return (vc);
} }
......
...@@ -75,7 +75,7 @@ struct vrt_backend_probe; ...@@ -75,7 +75,7 @@ struct vrt_backend_probe;
* backends to use. * 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 void vdi_fini_f(const struct director *);
typedef unsigned vdi_healthy(const struct director *, const uint8_t *digest); typedef unsigned vdi_healthy(const struct director *, const uint8_t *digest);
......
...@@ -101,17 +101,17 @@ VDI_RecycleFd(struct vbc **vbp) ...@@ -101,17 +101,17 @@ VDI_RecycleFd(struct vbc **vbp)
/* Get a connection --------------------------------------------------*/ /* Get a connection --------------------------------------------------*/
struct vbc * struct vbc *
VDI_GetFd(const struct director *d, struct req *req) VDI_GetFd(const struct director *d, struct busyobj *bo)
{ {
struct vbc *vc; struct vbc *vc;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
if (d == NULL) if (d == NULL)
d = req->director; d = bo->director;
CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
vc = d->getfd(d, req); vc = d->getfd(d, bo);
if (vc != NULL) if (vc != NULL)
vc->vsl = req->busyobj->vsl; vc->vsl = bo->vsl;
return (vc); return (vc);
} }
......
...@@ -383,7 +383,7 @@ FetchHdr(struct req *req, int need_host_hdr, int sendbody) ...@@ -383,7 +383,7 @@ FetchHdr(struct req *req, int need_host_hdr, int sendbody)
hp = bo->bereq; hp = bo->bereq;
bo->vbc = VDI_GetFd(NULL, req); bo->vbc = VDI_GetFd(NULL, bo);
if (bo->vbc == NULL) { if (bo->vbc == NULL) {
VSLb(req->vsl, SLT_FetchError, "no backend connection"); VSLb(req->vsl, SLT_FetchError, "no backend connection");
return (-1); return (-1);
......
...@@ -75,7 +75,7 @@ PipeRequest(struct req *req) ...@@ -75,7 +75,7 @@ PipeRequest(struct req *req)
bo = req->busyobj; bo = req->busyobj;
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
vc = VDI_GetFd(NULL, req); vc = VDI_GetFd(NULL, bo);
if (vc == NULL) if (vc == NULL)
return; return;
bo->vbc = vc; /* For panic dumping */ bo->vbc = vc; /* For panic dumping */
......
...@@ -54,7 +54,7 @@ vmod_rr_healthy(const struct director *dir, const uint8_t *digest) ...@@ -54,7 +54,7 @@ vmod_rr_healthy(const struct director *dir, const uint8_t *digest)
} }
static struct vbc * __match_proto__(vdi_getfd_f) 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; struct vmod_directors_fallback *rr;
unsigned u; unsigned u;
...@@ -65,13 +65,13 @@ vmod_rr_getfd(const struct director *dir, struct req *req) ...@@ -65,13 +65,13 @@ vmod_rr_getfd(const struct director *dir, struct req *req)
for (u = 0; u < rr->vd->n_backend; u++) { for (u = 0; u < rr->vd->n_backend; u++) {
be = rr->vd->backend[u]; be = rr->vd->backend[u];
CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC); CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC);
if (be->healthy(be, req->digest)) if (be->healthy(be, bo->digest))
break; break;
} }
vdir_unlock(rr->vd); vdir_unlock(rr->vd);
if (u == rr->vd->n_backend || be == NULL) if (u == rr->vd->n_backend || be == NULL)
return (NULL); return (NULL);
return (be->getfd(be, req)); return (be->getfd(be, bo));
} }
VCL_VOID __match_proto__() VCL_VOID __match_proto__()
......
...@@ -118,6 +118,6 @@ vmod_hash_backend(struct req *req, struct vmod_directors_hash *rr, const char *a ...@@ -118,6 +118,6 @@ vmod_hash_backend(struct req *req, struct vmod_directors_hash *rr, const char *a
r = vbe32dec(sha256); r = vbe32dec(sha256);
r = scalbn(r, -32); 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); return (be);
} }
...@@ -59,7 +59,7 @@ vmod_rr_healthy(const struct director *dir, const uint8_t *digest) ...@@ -59,7 +59,7 @@ vmod_rr_healthy(const struct director *dir, const uint8_t *digest)
} }
static struct vbc * __match_proto__(vdi_getfd_f) 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; struct vmod_directors_random *rr;
VCL_BACKEND be; VCL_BACKEND be;
...@@ -67,10 +67,10 @@ vmod_rr_getfd(const struct director *dir, struct req *req) ...@@ -67,10 +67,10 @@ vmod_rr_getfd(const struct director *dir, struct req *req)
CAST_OBJ_NOTNULL(rr, dir->priv, VMOD_DIRECTORS_RANDOM_MAGIC); CAST_OBJ_NOTNULL(rr, dir->priv, VMOD_DIRECTORS_RANDOM_MAGIC);
r = scalbn(random(), -31); 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) if (be == NULL)
return (NULL); return (NULL);
return (be->getfd(be, req)); return (be->getfd(be, bo));
} }
VCL_VOID __match_proto__() VCL_VOID __match_proto__()
......
...@@ -55,7 +55,7 @@ vmod_rr_healthy(const struct director *dir, const uint8_t *digest) ...@@ -55,7 +55,7 @@ vmod_rr_healthy(const struct director *dir, const uint8_t *digest)
} }
static struct vbc * __match_proto__(vdi_getfd_f) 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; struct vmod_directors_round_robin *rr;
unsigned u; unsigned u;
...@@ -68,13 +68,13 @@ vmod_rr_getfd(const struct director *dir, struct req *req) ...@@ -68,13 +68,13 @@ vmod_rr_getfd(const struct director *dir, struct req *req)
be = rr->vd->backend[rr->nxt]; be = rr->vd->backend[rr->nxt];
rr->nxt++; rr->nxt++;
CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC); CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC);
if (be->healthy(be, req->digest)) if (be->healthy(be, bo->digest))
break; break;
} }
vdir_unlock(rr->vd); vdir_unlock(rr->vd);
if (u == rr->vd->n_backend || be == NULL) if (u == rr->vd->n_backend || be == NULL)
return (NULL); return (NULL);
return (be->getfd(be, req)); return (be->getfd(be, bo));
} }
VCL_VOID __match_proto__() VCL_VOID __match_proto__()
......
...@@ -169,7 +169,8 @@ vdir_pick_by_weight(const struct vdir *vd, double w, ...@@ -169,7 +169,8 @@ vdir_pick_by_weight(const struct vdir *vd, double w,
} }
VCL_BACKEND 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; struct vbitmap *vbm = NULL;
unsigned u, v, l; unsigned u, v, l;
...@@ -185,7 +186,7 @@ vdir_pick_be(struct vdir *vd, const struct req *req, double w, unsigned nloops) ...@@ -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); u = vdir_pick_by_weight(vd, w * tw, vbm);
be = vd->backend[u]; be = vd->backend[u];
CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC); CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC);
if (be->healthy(be, req->digest)) if (be->healthy(be, bo->digest))
break; break;
if (l == 0) { if (l == 0) {
vbm = vd->vbm; vbm = vd->vbm;
......
...@@ -48,5 +48,5 @@ void vdir_lock(struct vdir *vd); ...@@ -48,5 +48,5 @@ void vdir_lock(struct vdir *vd);
void vdir_unlock(struct vdir *vd); void vdir_unlock(struct vdir *vd);
unsigned vdir_add_backend(struct vdir *vd, VCL_BACKEND be, double weight); unsigned vdir_add_backend(struct vdir *vd, VCL_BACKEND be, double weight);
unsigned vdir_any_healthy(struct vdir *vd, const uint8_t *digest); 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); unsigned nloops);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment