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}],
)
# 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
EXTRA_DEVELOPER_CFLAGS="-Wextra -Wno-missing-field-initializers -Wno-sign-compare"
......
......@@ -40,6 +40,7 @@
#include "cache/cache_director.h"
#include "vrt.h"
#include "vbm.h"
#include "vslp_hash.h"
#include "vslp_dir.h"
......@@ -48,7 +49,7 @@ typedef int (*compar)( const void*, const void* );
struct vslp_state {
struct vslpdir *vslpd;
uint64_t picklist;
struct vbitmap *picklist;
int idx;
const struct vrt_ctx *ctx;
};
......@@ -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)
return -1;
} while (state->picklist & (1 << chosen));
state->picklist |= 1 << chosen;
} while (vbit_test(state->picklist, chosen));
vbit_set(state->picklist, chosen);
return chosen;
}
......@@ -398,7 +399,11 @@ VCL_BACKEND vslpdir_pick_be(struct vslpdir *vslpd,
VCL_BACKEND be;
int chosen, be_choice = 0, restarts_o = 0, restarts = 0;
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(ctx, VRT_CTX_MAGIC);
AN(ctx->vsl);
......@@ -418,7 +423,6 @@ VCL_BACKEND vslpdir_pick_be(struct vslpdir *vslpd,
n_retry--;
}
state.picklist = 0;
state.vslpd = vslpd;
state.ctx = ctx;
......@@ -462,17 +466,17 @@ VCL_BACKEND vslpdir_pick_be(struct vslpdir *vslpd,
}
if(--restarts <= 0)
return be;
goto ok;
}
if (! be) {
VSLb(ctx->vsl, SLT_Debug, "VSLP no backend found");
return NULL;
goto err;
}
if (! healthy) {
AN(be);
return (be);
goto ok;
}
if (be->healthy(be, ctx->bo, NULL))
......@@ -512,6 +516,11 @@ VCL_BACKEND vslpdir_pick_be(struct vslpdir *vslpd,
}
}
ok:
vbit_destroy(state.picklist);
AN(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