Commit 402faa1d authored by Nils Goroll's avatar Nils Goroll

adjust to 6.0

parent 9051fee0
......@@ -33,6 +33,7 @@
#include <stdlib.h> // free/calloc
#include <cache/cache.h>
#include <cache/cache_director.h>
#include <vcl.h>
#include <vtim.h>
......@@ -48,22 +49,16 @@ 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 const struct vdi_methods vmod_director_methods[1] = {
{
.magic = VDI_METHODS_MAGIC,
.type = "all_healthy",
.resolve = vmod_director_resolve,
.healthy = vmod_director_healthy,
}
};
static VCL_BACKEND vmod_director_resolve(VCL_BACKEND, struct worker *,
struct busyobj *);
static VCL_BOOL vmod_director_healthy(VCL_BACKEND, const struct busyobj *,
VCL_TIME *);
VCL_VOID
vmod_director__init(VRT_CTX,
struct vmod_all_healthy_director **dp, const char *vcl_name)
{
struct director *dir;
struct vmod_all_healthy_director *d;
const int spc = 4;
......@@ -80,11 +75,20 @@ vmod_director__init(VRT_CTX,
goto fail_consider;
}
d->spcconsider = spc;
d->dir = VRT_AddDirector(ctx, vmod_director_methods, d, "%s", vcl_name);
if (d->dir == NULL) {
VRT_fail(ctx, "AddDirector failed");
ALLOC_OBJ(dir, DIRECTOR_MAGIC);
if (dir == NULL) {
VRT_fail(ctx, "director alloc failed");
goto fail_dir;
}
dir->name = "all_healthy";
REPLACE(dir->vcl_name, vcl_name);
dir->priv = d;
dir->healthy = vmod_director_healthy;
dir->resolve = vmod_director_resolve;
dir->admin_health = VDI_AH_HEALTHY;
d->dir = dir;
*dp = d;
return;
......@@ -103,7 +107,8 @@ vmod_director__fini(struct vmod_all_healthy_director **dp) {
if (d == NULL)
return;
CHECK_OBJ(d, VMOD_ALL_HEALTHY_DIRECTOR_MAGIC);
VRT_DelDirector(&d->dir);
free(TRUST_ME(d->dir->vcl_name));
free(TRUST_ME(d->dir));
free(TRUST_ME(d->consider));
FREE_OBJ(d);
}
......@@ -176,11 +181,14 @@ 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)
static VCL_BACKEND vmod_director_resolve(VCL_BACKEND b, struct worker *w,
struct busyobj *bo)
{
struct vmod_all_healthy_director *d;
CAST_OBJ_NOTNULL(d, b->priv, VMOD_ALL_HEALTHY_DIRECTOR_MAGIC);
(void) w;
(void) b;
return (d->backend);
}
......@@ -196,7 +204,8 @@ static VCL_BACKEND vmod_director_resolve(VRT_CTX, VCL_BACKEND b)
*/
static VCL_BOOL
vmod_director_healthy(VRT_CTX, VCL_BACKEND b, VCL_TIME *t)
vmod_director_healthy(VCL_BACKEND b, const struct busyobj *bo,
VCL_TIME *t)
{
struct vmod_all_healthy_director *d;
int i;
......@@ -204,7 +213,6 @@ vmod_director_healthy(VRT_CTX, VCL_BACKEND b, VCL_TIME *t)
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) {
......@@ -215,7 +223,7 @@ vmod_director_healthy(VRT_CTX, VCL_BACKEND b, VCL_TIME *t)
for (i = 0; i < d->nconsider; i++) {
be = d->consider[i];
CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC);
br = !!VRT_Healthy(ctx, be, &bt);
br = !!be->healthy(be, bo, &bt);
r &= br;
if (t) {
if (r && br) {
......
......@@ -24,7 +24,7 @@ varnish v1 -vcl {
}
} -start
varnish v1 -cliok "backend.list -j"
varnish v1 -cliok "backend.list"
client c1 {
txreq
......@@ -38,7 +38,7 @@ client c1 {
varnish v1 -cliok "backend.set_health be_a sick"
varnish v1 -cliok "backend.list -j"
varnish v1 -cliok "backend.list"
client c1 {
txreq
......@@ -53,7 +53,7 @@ client c1 {
varnish v1 -cliok "backend.set_health be_a healthy"
varnish v1 -cliok "backend.set_health be_b sick"
varnish v1 -cliok "backend.list -j"
varnish v1 -cliok "backend.list"
client c1 {
txreq
......@@ -67,7 +67,7 @@ client c1 {
varnish v1 -cliok "backend.set_health be_b healthy"
varnish v1 -cliok "backend.list -j"
varnish v1 -cliok "backend.list"
client c1 {
txreq
......
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