Commit 13a03e3a authored by Reza Naghibi's avatar Reza Naghibi

Allow shard.reconfigure() to work on empty directors

Also move the lock up to cover more operations.
parent 349abc76
varnishtest "Empty shard reconfig"
server s1 {
rxreq
txresp
} -start
varnish v1 -vcl+backend {
import directors;
sub vcl_init {
new shard1 = directors.shard();
new shard2 = directors.shard();
shard1.reconfigure();
shard2.add_backend(s1);
shard2.reconfigure();
}
sub vcl_recv {
set req.backend_hint = shard2.backend();
}
} -start
client c1 {
txreq
rxresp
expect resp.status == 200
} -run
......@@ -616,14 +616,19 @@ shardcfg_reconfigure(VRT_CTX, struct vmod_priv *priv,
return (0);
}
sharddir_wrlock(shardd);
change = shard_change_get(ctx, priv, shardd);
if (change == NULL)
if (change == NULL) {
sharddir_unlock(shardd);
return (0);
}
if (VSTAILQ_FIRST(&change->tasks) == NULL)
if (VSTAILQ_FIRST(&change->tasks) == NULL) {
shard_change_finish(change);
sharddir_unlock(shardd);
return (1);
sharddir_wrlock(shardd);
}
shardcfg_apply_change(ctx, shardd, change, replicas);
shard_change_finish(change);
......
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