Commit c585468a authored by Geoff Simmons's avatar Geoff Simmons

delete() can only remove backends created by this VMOD in the current

VCL
parent 62a90186
...@@ -291,29 +291,33 @@ VCL_BOOL ...@@ -291,29 +291,33 @@ 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 backend *backend;
struct belist *belist;
struct bentry *bentry;
const struct director *dir = NULL;
AN(priv); AN(priv);
if (priv->priv == NULL)
return 0;
if (be == NULL) if (be == NULL)
return 0; return 0;
backend = check_and_get_backend(ctx, be); backend = check_and_get_backend(ctx, be);
if (backend == NULL) if (backend == NULL)
return 0; return 0;
if (priv->priv != NULL) { CAST_OBJ(belist, priv->priv, BELIST_MAGIC);
struct belist *belist; AN(belist->behead);
struct bentry *bentry; VTAILQ_FOREACH(bentry, belist->behead, bentry) {
CHECK_OBJ_NOTNULL(bentry, BENTRY_MAGIC);
CAST_OBJ(belist, priv->priv, BELIST_MAGIC); CHECK_OBJ_NOTNULL(bentry->be, DIRECTOR_MAGIC);
AN(belist->behead); if (bentry->be == be) {
VTAILQ_FOREACH(bentry, belist->behead, bentry) { dir = be;
CHECK_OBJ_NOTNULL(bentry, BENTRY_MAGIC); VTAILQ_REMOVE(belist->behead, bentry, bentry);
CHECK_OBJ_NOTNULL(bentry->be, DIRECTOR_MAGIC); break;
if (bentry->be == be) {
VTAILQ_REMOVE(belist->behead, bentry, bentry);
break;
}
} }
} }
if (dir == NULL)
return 0;
VCL_DelBackend(backend); VCL_DelBackend(backend);
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