Commit f637f06a authored by Nils Goroll's avatar Nils Goroll

varnish now has event workspace, use it. Fail gracefully for out-of-workspace

parent 3b72a3bd
......@@ -61,7 +61,6 @@ struct shard_change {
#define SHARD_CHANGE_MAGIC 0xdff5c9a6
const struct sharddir *shardd;
void *space;
struct ws *ws;
VSTAILQ_HEAD(,shard_change_task) tasks;
};
......@@ -82,15 +81,6 @@ struct backend_reconfig {
* for now, we allow to only reconfigure one shard director at a time.
*/
static void
shard_change_free_ws(void *priv)
{
struct shard_change *f;
CAST_OBJ_NOTNULL(f, priv, SHARD_CHANGE_MAGIC);
AN(f->space);
free(f->space);
}
static struct shard_change *
shard_change_get(VRT_CTX, struct vmod_priv *priv,
const struct sharddir * const shardd)
......@@ -111,28 +101,14 @@ shard_change_get(VRT_CTX, struct vmod_priv *priv,
return (change);
}
if (ctx->ws) {
change = WS_Alloc(ctx->ws, sizeof(*change));
AN(change);
INIT_OBJ(change, SHARD_CHANGE_MAGIC);
change->space = NULL;
change->ws = ctx->ws;
} else {
// XXX should be default in core #2063
struct ws *ws;
char *space = malloc(cache_param->workspace_client);
AN(space);
ws = (void *)space;
WS_Init(ws, "shd", space + sizeof(*ws),
cache_param->workspace_client - sizeof(*ws));
change = WS_Alloc(ws, sizeof(*change));
AN(change);
INIT_OBJ(change, SHARD_CHANGE_MAGIC);
change->space = space;
change->ws = ws;
priv->free = shard_change_free_ws;
change = WS_Alloc(ctx->ws, sizeof(*change));
if (change == NULL) {
shard_err0(ctx, shardd, "could not get workspace");
return NULL;
}
INIT_OBJ(change, SHARD_CHANGE_MAGIC);
change->space = NULL;
change->shardd = shardd;
VSTAILQ_INIT(&change->tasks);
priv->priv = change;
......@@ -150,15 +126,19 @@ shard_change_finish(struct shard_change *change)
}
static void
shard_change_task_add(struct shard_change *change,
shard_change_task_add(VRT_CTX, struct shard_change *change,
enum shard_change_task_e task_e, void *priv)
{
struct shard_change_task *task;
CHECK_OBJ_NOTNULL(change, SHARD_CHANGE_MAGIC);
task = WS_Alloc(change->ws, sizeof(*task));
AN(task);
task = WS_Alloc(ctx->ws, sizeof(*task));
if (task == NULL) {
shard_err0(ctx, change->shardd,
"could not get workspace for task");
return;
}
INIT_OBJ(task, SHARD_CHANGE_TASK_MAGIC);
task->task = task_e;
task->priv = priv;
......@@ -181,7 +161,7 @@ shard_change_task_backend(VRT_CTX,
if (change == NULL)
return 0;
b = WS_Alloc(change->ws, sizeof(*b));
b = WS_Alloc(ctx->ws, sizeof(*b));
if (b == NULL) {
shard_err(ctx, shardd, ".%s_backend() WS_Alloc() failed",
task_e == ADD_BE ? "add" : "remove");
......@@ -192,7 +172,7 @@ shard_change_task_backend(VRT_CTX,
b->ident = ident != NULL && *ident != '\0' ? ident : NULL;
b->rampup = rampup;
shard_change_task_add(change, task_e, b);
shard_change_task_add(ctx, change, task_e, b);
return 1;
}
......@@ -229,7 +209,7 @@ shardcfg_clear(VRT_CTX, struct vmod_priv *priv, struct sharddir *shardd)
if (change == NULL)
return 0;
shard_change_task_add(change, CLEAR, NULL);
shard_change_task_add(ctx, change, CLEAR, NULL);
return 1;
}
......
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