Commit 68fc5f9a authored by Nils Goroll's avatar Nils Goroll

pass the busyobj (if any) when checking health, comment, remove unused function

parent 3002afbf
...@@ -48,11 +48,11 @@ ...@@ -48,11 +48,11 @@
typedef int (*compar)( const void*, const void* ); typedef int (*compar)( const void*, const void* );
struct vslp_state { struct vslp_state {
const struct vrt_ctx *ctx;
struct vslpdir *vslpd; struct vslpdir *vslpd;
struct vbitmap *picklist; struct vbitmap *picklist;
/* start index in the hashcircle for our key */ /* start index in the hashcircle for our key */
int idx; int idx;
const struct vrt_ctx *ctx;
}; };
static int static int
...@@ -183,7 +183,7 @@ vslp_choose_next_healthy(struct vslp_state *state, uint32_t n_retry) ...@@ -183,7 +183,7 @@ vslp_choose_next_healthy(struct vslp_state *state, uint32_t n_retry)
be = state->vslpd->backend[chosen]; be = state->vslpd->backend[chosen];
AN(be); AN(be);
if(be->healthy(be, NULL, NULL)) if(be->healthy(be, state->ctx->bo, NULL))
{ {
vslp_be_healthy(state, chosen); vslp_be_healthy(state, chosen);
break; break;
...@@ -363,29 +363,22 @@ void vslpdir_expand(struct vslpdir *vslpd, unsigned n) ...@@ -363,29 +363,22 @@ void vslpdir_expand(struct vslpdir *vslpd, unsigned n)
vslpd->l_backend = n; vslpd->l_backend = n;
} }
unsigned
vslpdir_any_healthy(struct vslpdir *vslpd)
{
unsigned retval = 0;
VCL_BACKEND be;
unsigned u;
CHECK_OBJ_NOTNULL(vslpd, VSLPDIR_MAGIC);
vslpdir_lock(vslpd);
for (u = 0; u < vslpd->n_backend; u++) {
be = vslpd->backend[u];
CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC);
if (be->healthy(be, NULL, NULL)) {
retval = 1;
break;
}
}
vslpdir_unlock(vslpd);
return (retval);
}
/* /*
* core function for the director backend method
*
* while other directors return a reference to their own backend object (on
* which varnish will call the resolve method to resolve to a non-director
* backend), this director immediately reolves in the backend method, to make
* the director choice visible in VCL
*
* consequences:
* - we need no own struct director
* - we can only respect a busy object when being called on the backend side,
* which probably is, for all practical purposes, only relevant when the
* saintmode vmod is used
*
* arguments:
*
* hash: position on the ring * hash: position on the ring
* n_retry: * n_retry:
* 0 : choose n-th backend based on number of restarts / retries * 0 : choose n-th backend based on number of restarts / retries
...@@ -410,8 +403,8 @@ VCL_BACKEND vslpdir_pick_be(struct vslpdir *vslpd, ...@@ -410,8 +403,8 @@ VCL_BACKEND vslpdir_pick_be(struct vslpdir *vslpd,
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
AN(ctx->vsl); AN(ctx->vsl);
state.vslpd = vslpd;
state.ctx = ctx; state.ctx = ctx;
state.vslpd = vslpd;
state.picklist = vbit_init(picklist_spc, picklist_sz); state.picklist = vbit_init(picklist_spc, picklist_sz);
AN(state.picklist); AN(state.picklist);
......
...@@ -71,6 +71,5 @@ void vslpdir_init_hashcircle(struct vslpdir *vslpd, VCL_INT replicas); ...@@ -71,6 +71,5 @@ void vslpdir_init_hashcircle(struct vslpdir *vslpd, VCL_INT replicas);
void vslpdir_lock(struct vslpdir *vslpd); void vslpdir_lock(struct vslpdir *vslpd);
void vslpdir_unlock(struct vslpdir *vslpd); void vslpdir_unlock(struct vslpdir *vslpd);
void vslpdir_expand(struct vslpdir *vslpd, unsigned n); void vslpdir_expand(struct vslpdir *vslpd, unsigned n);
unsigned vslpdir_any_healthy(struct vslpdir *vslpd);
VCL_BACKEND vslpdir_pick_be(struct vslpdir *vslpd, const struct vrt_ctx *ctx, uint32_t hash, VCL_BACKEND vslpdir_pick_be(struct vslpdir *vslpd, const struct vrt_ctx *ctx, uint32_t hash,
VCL_INT n_retry, VCL_BOOL altsrv_p, VCL_BOOL healthy); VCL_INT n_retry, VCL_BOOL altsrv_p, VCL_BOOL healthy);
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