Commit a328dd6b authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Reduce to just one backend health-check variant.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@5568 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent fdd871ad
......@@ -526,7 +526,6 @@ extern pthread_t VCA_thread;
void VBE_UseHealth(const struct director *vdi);
struct vbc *VDI_GetFd(const struct director *, struct sess *sp);
int VDI_Healthy_x(double now, const struct director *, uintptr_t target);
int VDI_Healthy(const struct director *, const struct sess *sp);
void VDI_CloseFd(struct sess *sp);
void VDI_RecycleFd(struct sess *sp);
......
......@@ -483,13 +483,13 @@ vdi_simple_getfd(const struct director *d, struct sess *sp)
}
static unsigned
vdi_simple_healthy(double now, const struct director *d, uintptr_t target)
vdi_simple_healthy(const struct director *d, const struct sess *sp)
{
struct vdi_simple *vs;
CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC);
return (vbe_Healthy(now, target, vs));
return (vbe_Healthy(sp->t_req, (uintptr_t)(sp->objhead), vs));
}
static void
......
......@@ -79,8 +79,7 @@ struct vrt_backend_probe;
typedef struct vbc *vdi_getfd_f(const struct director *, struct sess *sp);
typedef void vdi_fini_f(const struct director *);
typedef unsigned vdi_healthy(double now, const struct director *,
uintptr_t target);
typedef unsigned vdi_healthy(const struct director *, const struct sess *sp);
struct director {
unsigned magic;
......
......@@ -116,13 +116,5 @@ VDI_Healthy(const struct director *d, const struct sess *sp)
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
return (d->healthy(sp->t_req, d, (uintptr_t)sp->objhead));
}
int
VDI_Healthy_x(double now, const struct director *d, uintptr_t target)
{
CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
return (d->healthy(now, d, target));
return (d->healthy(d, sp));
}
......@@ -398,15 +398,14 @@ vdi_dns_getfd(const struct director *director, struct sess *sp)
}
static unsigned
vdi_dns_healthy(double now, const struct director *dir, uintptr_t target)
vdi_dns_healthy(const struct director *dir, const struct sess *sp)
{
/* XXX: Fooling -Werror for a bit until it's actually implemented.
*/
if (now || dir || target)
return (1);
else
return (1);
(void)dir;
(void)sp;
return (1);
/*
struct vdi_dns *vs;
struct director *dir;
......
......@@ -188,7 +188,7 @@ vdi_random_getfd(const struct director *d, struct sess *sp)
}
static unsigned
vdi_random_healthy(double now, const struct director *d, uintptr_t target)
vdi_random_healthy(const struct director *d, const struct sess *sp)
{
struct vdi_random *vs;
int i;
......@@ -197,10 +197,10 @@ vdi_random_healthy(double now, const struct director *d, uintptr_t target)
CAST_OBJ_NOTNULL(vs, d->priv, VDI_RANDOM_MAGIC);
for (i = 0; i < vs->nhosts; i++) {
if (VDI_Healthy_x(now, vs->hosts[i].backend, target))
return 1;
if (VDI_Healthy(vs->hosts[i].backend, sp))
return (1);
}
return 0;
return (0);
}
static void
......
......@@ -85,7 +85,7 @@ vdi_round_robin_getfd(const struct director *d, struct sess *sp)
}
static unsigned
vdi_round_robin_healthy(double now, const struct director *d, uintptr_t target)
vdi_round_robin_healthy(const struct director *d, const struct sess *sp)
{
struct vdi_round_robin *vs;
struct director *backend;
......@@ -96,10 +96,10 @@ vdi_round_robin_healthy(double now, const struct director *d, uintptr_t target)
for (i = 0; i < vs->nhosts; i++) {
backend = vs->hosts[i].backend;
if (VDI_Healthy_x(now, backend, target))
return 1;
if (VDI_Healthy(backend, sp))
return (1);
}
return 0;
return (0);
}
static void
......
......@@ -383,23 +383,26 @@ HSH_Lookup(struct sess *sp, struct objhead **poh)
/*
* If we have seen a busy object or the backend is unhealthy, and
* have an object in grace, use it, if req.grace is also
* we have an object in grace, use it, if req.grace is also
* satisified.
* XXX: Interesting footnote: The busy object might be for a
* XXX: different "Vary:" than we sought. We have no way of knowing
* XXX: this until the object is unbusy'ed, so in practice we
* XXX: serialize fetch of all Vary's if grace is possible.
*/
AZ(sp->objhead);
sp->objhead = oh; /* XXX: Hack */
if (oc == NULL /* We found no live object */
&& grace_oc != NULL /* There is a grace candidate */
&& (busy_oc != NULL /* Somebody else is already busy */
|| !VDI_Healthy_x(sp->t_req, sp->director, (uintptr_t)oh))) {
|| !VDI_Healthy(sp->director, sp))) {
/* Or it is impossible to fetch */
o = oc_getobj(sp->wrk, grace_oc);
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
if (o->ttl + HSH_Grace(sp->grace) >= sp->t_req)
oc = grace_oc;
}
sp->objhead = NULL;
if (oc != NULL && !sp->hash_always_miss) {
o = oc_getobj(sp->wrk, oc);
......
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