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);
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);
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -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 */
......
......@@ -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__()
......
......@@ -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);
}
......@@ -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__()
......
......@@ -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__()
......
......@@ -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;
......
......@@ -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);
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