Commit b351e28f authored by Nils Goroll's avatar Nils Goroll

use the vbm facility for the picklist

parent 21cecbee
...@@ -88,7 +88,7 @@ AS_CASE([${VMOD_ABI_VERSION}], ...@@ -88,7 +88,7 @@ AS_CASE([${VMOD_ABI_VERSION}],
) )
# This corresponds to FreeBSD's WARNS level 6 # This corresponds to FreeBSD's WARNS level 6
DEVELOPER_CFLAGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wcast-align -Wunused-parameter -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls -Wformat" DEVELOPER_CFLAGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wcast-align -Wunused-parameter -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls -Wformat -Wno-free-nonheap-object"
# Additional flags for GCC 4 # Additional flags for GCC 4
EXTRA_DEVELOPER_CFLAGS="-Wextra -Wno-missing-field-initializers -Wno-sign-compare" EXTRA_DEVELOPER_CFLAGS="-Wextra -Wno-missing-field-initializers -Wno-sign-compare"
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "cache/cache_director.h" #include "cache/cache_director.h"
#include "vrt.h" #include "vrt.h"
#include "vbm.h"
#include "vslp_hash.h" #include "vslp_hash.h"
#include "vslp_dir.h" #include "vslp_dir.h"
...@@ -48,7 +49,7 @@ typedef int (*compar)( const void*, const void* ); ...@@ -48,7 +49,7 @@ typedef int (*compar)( const void*, const void* );
struct vslp_state { struct vslp_state {
struct vslpdir *vslpd; struct vslpdir *vslpd;
uint64_t picklist; struct vbitmap *picklist;
int idx; int idx;
const struct vrt_ctx *ctx; const struct vrt_ctx *ctx;
}; };
...@@ -156,8 +157,8 @@ vslp_choose_next(struct vslp_state *state, uint32_t n_retry) ...@@ -156,8 +157,8 @@ vslp_choose_next(struct vslp_state *state, uint32_t n_retry)
state->vslpd->n_backend * state->vslpd->replicas + state->vslpd->n_backend * state->vslpd->replicas +
state->vslpd->n_backend) state->vslpd->n_backend)
return -1; return -1;
} while (state->picklist & (1 << chosen)); } while (vbit_test(state->picklist, chosen));
state->picklist |= 1 << chosen; vbit_set(state->picklist, chosen);
return chosen; return chosen;
} }
...@@ -398,7 +399,11 @@ VCL_BACKEND vslpdir_pick_be(struct vslpdir *vslpd, ...@@ -398,7 +399,11 @@ VCL_BACKEND vslpdir_pick_be(struct vslpdir *vslpd,
VCL_BACKEND be; VCL_BACKEND be;
int chosen, be_choice = 0, restarts_o = 0, restarts = 0; int chosen, be_choice = 0, restarts_o = 0, restarts = 0;
struct vslp_state state; struct vslp_state state;
unsigned picklist_sz = VBITMAP_SZ(vslpd->n_backend);
char picklist_spc[picklist_sz];
state.picklist = vbit_init(picklist_spc, picklist_sz);
AN(state.picklist);
CHECK_OBJ_NOTNULL(vslpd, VSLPDIR_MAGIC); CHECK_OBJ_NOTNULL(vslpd, VSLPDIR_MAGIC);
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
AN(ctx->vsl); AN(ctx->vsl);
...@@ -418,7 +423,6 @@ VCL_BACKEND vslpdir_pick_be(struct vslpdir *vslpd, ...@@ -418,7 +423,6 @@ VCL_BACKEND vslpdir_pick_be(struct vslpdir *vslpd,
n_retry--; n_retry--;
} }
state.picklist = 0;
state.vslpd = vslpd; state.vslpd = vslpd;
state.ctx = ctx; state.ctx = ctx;
...@@ -462,17 +466,17 @@ VCL_BACKEND vslpdir_pick_be(struct vslpdir *vslpd, ...@@ -462,17 +466,17 @@ VCL_BACKEND vslpdir_pick_be(struct vslpdir *vslpd,
} }
if(--restarts <= 0) if(--restarts <= 0)
return be; goto ok;
} }
if (! be) { if (! be) {
VSLb(ctx->vsl, SLT_Debug, "VSLP no backend found"); VSLb(ctx->vsl, SLT_Debug, "VSLP no backend found");
return NULL; goto err;
} }
if (! healthy) { if (! healthy) {
AN(be); AN(be);
return (be); goto ok;
} }
if (be->healthy(be, ctx->bo, NULL)) if (be->healthy(be, ctx->bo, NULL))
...@@ -512,6 +516,11 @@ VCL_BACKEND vslpdir_pick_be(struct vslpdir *vslpd, ...@@ -512,6 +516,11 @@ VCL_BACKEND vslpdir_pick_be(struct vslpdir *vslpd,
} }
} }
ok:
vbit_destroy(state.picklist);
AN(be); AN(be);
return (be); return (be);
err:
vbit_destroy(state.picklist);
return NULL;
} }
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