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

adjust to 6.0

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