Commit 977cde57 authored by Geoff Simmons's avatar Geoff Simmons

use VRT_delete_backend() to delete backends, this behaves better with

backend.list, for example. Also remove the extra checking in delete(),
since we only delete backends created by the VMOD.
parent b4281001
......@@ -41,10 +41,12 @@ client c1 {
expect resp.status == 503
} -run
# VCL_DelBackend() does not decrement n_backend, nor does it remove
# the backend from the output of backend.list
# n_backend is not decremented until 60 seconds after backend cooldown
varnish v1 -expect MAIN.n_backend == 2
# varnish v1 -expect MAIN.n_backend == 1
# The deleted backend does not appear in the output of backend.list
# Verify this by inspecting the log
varnish v1 -cliok backend.list
# Cannot delete a backend not defined by the VMOD
varnish v1 -vcl {
......
......@@ -268,10 +268,9 @@ vmod_by_name(VRT_CTX, struct vmod_priv *priv, VCL_STRING name)
VCL_BOOL
vmod_delete(VRT_CTX, struct vmod_priv *priv, VCL_BACKEND be)
{
struct backend *backend;
struct belist *belist;
struct bentry *bentry;
const struct director *dir = NULL;
struct director *dir = NULL;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
AN(priv);
......@@ -280,17 +279,6 @@ vmod_delete(VRT_CTX, struct vmod_priv *priv, VCL_BACKEND be)
if (be == NULL)
return 0;
CHECK_OBJ(be, DIRECTOR_MAGIC);
if (be->priv == NULL) {
errmsg(ctx, "vmod backend_dyn error: %s is not a leaf backend",
be->vcl_name);
return 0;
}
backend = (struct backend *) be->priv;
if (backend->magic != BACKEND_MAGIC) {
errmsg(ctx, "vmod backend_dyn error: "
"%s is not a standard backend", be->vcl_name);
return 0;
}
CAST_OBJ(belist, priv->priv, BELIST_MAGIC);
AN(belist->behead);
......@@ -298,15 +286,15 @@ vmod_delete(VRT_CTX, struct vmod_priv *priv, VCL_BACKEND be)
CHECK_OBJ_NOTNULL(bentry, BENTRY_MAGIC);
CHECK_OBJ_NOTNULL(bentry->be, DIRECTOR_MAGIC);
if (bentry->be == be) {
dir = be;
dir = bentry->be;
VTAILQ_REMOVE(belist->behead, bentry, bentry);
break;
}
}
if (dir == NULL)
return 0;
VCL_DelBackend(backend);
VRT_delete_backend(ctx, &dir);
AZ(dir);
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