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 { ...@@ -41,10 +41,12 @@ client c1 {
expect resp.status == 503 expect resp.status == 503
} -run } -run
# VCL_DelBackend() does not decrement n_backend, nor does it remove # n_backend is not decremented until 60 seconds after backend cooldown
# the backend from the output of backend.list 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 # Cannot delete a backend not defined by the VMOD
varnish v1 -vcl { varnish v1 -vcl {
......
...@@ -268,10 +268,9 @@ vmod_by_name(VRT_CTX, struct vmod_priv *priv, VCL_STRING name) ...@@ -268,10 +268,9 @@ vmod_by_name(VRT_CTX, struct vmod_priv *priv, VCL_STRING name)
VCL_BOOL VCL_BOOL
vmod_delete(VRT_CTX, struct vmod_priv *priv, VCL_BACKEND be) vmod_delete(VRT_CTX, struct vmod_priv *priv, VCL_BACKEND be)
{ {
struct backend *backend;
struct belist *belist; struct belist *belist;
struct bentry *bentry; struct bentry *bentry;
const struct director *dir = NULL; struct director *dir = NULL;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
AN(priv); AN(priv);
...@@ -280,17 +279,6 @@ vmod_delete(VRT_CTX, struct vmod_priv *priv, VCL_BACKEND be) ...@@ -280,17 +279,6 @@ vmod_delete(VRT_CTX, struct vmod_priv *priv, VCL_BACKEND be)
if (be == NULL) if (be == NULL)
return 0; return 0;
CHECK_OBJ(be, DIRECTOR_MAGIC); 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); CAST_OBJ(belist, priv->priv, BELIST_MAGIC);
AN(belist->behead); AN(belist->behead);
...@@ -298,15 +286,15 @@ vmod_delete(VRT_CTX, struct vmod_priv *priv, VCL_BACKEND be) ...@@ -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, BENTRY_MAGIC);
CHECK_OBJ_NOTNULL(bentry->be, DIRECTOR_MAGIC); CHECK_OBJ_NOTNULL(bentry->be, DIRECTOR_MAGIC);
if (bentry->be == be) { if (bentry->be == be) {
dir = be; dir = bentry->be;
VTAILQ_REMOVE(belist->behead, bentry, bentry); VTAILQ_REMOVE(belist->behead, bentry, bentry);
break; break;
} }
} }
if (dir == NULL) if (dir == NULL)
return 0; return 0;
VRT_delete_backend(ctx, &dir);
VCL_DelBackend(backend); AZ(dir);
return 1; 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