Move code - no other changes

parent 048ba45c
......@@ -48,8 +48,64 @@ struct vmod_all_healthy_director {
VCL_BACKEND *consider;
};
static VCL_BACKEND vmod_director_resolve(VRT_CTX, VCL_BACKEND);
static VCL_BOOL vmod_director_healthy(VRT_CTX, VCL_BACKEND, VCL_TIME *);
static VCL_BACKEND vmod_director_resolve(VRT_CTX, VCL_BACKEND b)
{
struct vmod_all_healthy_director *d;
CAST_OBJ_NOTNULL(d, b->priv, VMOD_ALL_HEALTHY_DIRECTOR_MAGIC);
return (d->backend);
}
/*
* we can only approximate the change time for the unhealthy case because we do
* not have the full record: consider all backends healthy, a goes down, then b,
* a comes back up: we would need to record the time a went down initially. We
* approximate by returning the time b went down, so:
*
* - unhealthy: earliest change of unhealthy backend
* - healthy: latest change of healthy backend
*/
static VCL_BOOL
vmod_director_healthy(VRT_CTX, VCL_BACKEND b, VCL_TIME *t)
{
struct vmod_all_healthy_director *d;
int i;
VCL_BOOL br, r = 1;
VCL_TIME bt, tt[2];
VCL_BACKEND be;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CAST_OBJ_NOTNULL(d, b->priv, VMOD_ALL_HEALTHY_DIRECTOR_MAGIC);
if (t) {
tt[0] = VTIM_real();
tt[1] = 0.0;
}
for (i = 0; i < d->nconsider; i++) {
be = d->consider[i];
CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC);
br = !!VRT_Healthy(ctx, be, &bt);
r &= br;
if (t) {
if (r && br) {
if (bt > tt[1])
tt[1] = bt;
} else if (! br) {
if (bt < tt[0])
tt[0] = bt;
}
}
}
assert(r == 0 || r == 1);
if (t)
*t = tt[r];
return (r);
}
static const struct vdi_methods vmod_director_methods[1] = {
{
......@@ -180,62 +236,3 @@ vmod_director_backend(VRT_CTX, struct vmod_all_healthy_director *d)
return (d->dir);
}
static VCL_BACKEND vmod_director_resolve(VRT_CTX, VCL_BACKEND b)
{
struct vmod_all_healthy_director *d;
CAST_OBJ_NOTNULL(d, b->priv, VMOD_ALL_HEALTHY_DIRECTOR_MAGIC);
return (d->backend);
}
/*
* we can only approximate the change time for the unhealthy case because we do
* not have the full record: consider all backends healthy, a goes down, then b,
* a comes back up: we would need to record the time a went down initially. We
* approximate by returning the time b went down, so:
*
* - unhealthy: earliest change of unhealthy backend
* - healthy: latest change of healthy backend
*/
static VCL_BOOL
vmod_director_healthy(VRT_CTX, VCL_BACKEND b, VCL_TIME *t)
{
struct vmod_all_healthy_director *d;
int i;
VCL_BOOL br, r = 1;
VCL_TIME bt, tt[2];
VCL_BACKEND be;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CAST_OBJ_NOTNULL(d, b->priv, VMOD_ALL_HEALTHY_DIRECTOR_MAGIC);
if (t) {
tt[0] = VTIM_real();
tt[1] = 0.0;
}
for (i = 0; i < d->nconsider; i++) {
be = d->consider[i];
CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC);
br = !!VRT_Healthy(ctx, be, &bt);
r &= br;
if (t) {
if (r && br) {
if (bt > tt[1])
tt[1] = bt;
} else if (! br) {
if (bt < tt[0])
tt[0] = bt;
}
}
}
assert(r == 0 || r == 1);
if (t)
*t = tt[r];
return (r);
}
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