[master] 5df6f8d46 Change VRT_re[fl]_vcl() to VRT_VCL_{Prevent|Allow}_Discard()
Poul-Henning Kamp
phk at FreeBSD.org
Tue May 7 17:07:10 UTC 2019
commit 5df6f8d46cb08ae435f866b8e6c1bb333cebdee3
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue May 7 14:47:38 2019 +0000
Change VRT_re[fl]_vcl() to VRT_VCL_{Prevent|Allow}_Discard()
diff --git a/bin/varnishd/cache/cache_vcl.h b/bin/varnishd/cache/cache_vcl.h
index aa530cb5b..d0154266f 100644
--- a/bin/varnishd/cache/cache_vcl.h
+++ b/bin/varnishd/cache/cache_vcl.h
@@ -60,7 +60,7 @@ struct vcl {
struct vclref {
unsigned magic;
#define VCLREF_MAGIC 0x47fb6848
- const struct vcl *vcl;
+ struct vcl *vcl;
VTAILQ_ENTRY(vclref) list;
char desc[32];
};
diff --git a/bin/varnishd/cache/cache_vrt_vcl.c b/bin/varnishd/cache/cache_vrt_vcl.c
index 30fd2a26a..db1e15243 100644
--- a/bin/varnishd/cache/cache_vrt_vcl.c
+++ b/bin/varnishd/cache/cache_vrt_vcl.c
@@ -323,7 +323,7 @@ VCL_DefaultProbe(const struct vcl *vcl)
}
struct vclref *
-VRT_ref_vcl(VRT_CTX, const char *desc)
+VRT_VCL_Prevent_Discard(VRT_CTX, const char *desc)
{
struct vcl *vcl;
struct vclref* ref;
@@ -351,7 +351,7 @@ VRT_ref_vcl(VRT_CTX, const char *desc)
}
void
-VRT_rel_vcl(VRT_CTX, struct vclref **refp)
+VRT_VCL_Allow_Discard(struct vclref **refp)
{
struct vcl *vcl;
struct vclref *ref;
@@ -360,12 +360,9 @@ VRT_rel_vcl(VRT_CTX, struct vclref **refp)
ref = *refp;
*refp = NULL;
- CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ref, VCLREF_MAGIC);
-
- vcl = ctx->vcl;
+ vcl = ref->vcl;
CHECK_OBJ_NOTNULL(vcl, VCL_MAGIC);
- assert(vcl == ref->vcl);
/* NB: A VCL may be released by a VMOD at any time, but it must happen
* after a warmup and before the end of a cooldown. The release may or
diff --git a/include/vrt.h b/include/vrt.h
index f5789e9e0..8db9bf88c 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -52,6 +52,7 @@
* binary/load-time compatible, increment MAJOR version
*
* unreleased (planned for 2019-09-15)
+ * VRT_re[fl]_vcl changed to VRT_VCL_{Prevent|Allow}_Discard
* VRT_Vmod_{Init|Unload} moved to vcc_interface.h
* VRT_count moved to vcc_interface.h
* VRT_VCL_Busy() and VRT_VCL_Unbusy() added.
@@ -523,8 +524,8 @@ struct vmod_priv {
};
struct vclref;
-struct vclref * VRT_ref_vcl(VRT_CTX, const char *);
-void VRT_rel_vcl(VRT_CTX, struct vclref **);
+struct vclref * VRT_VCL_Prevent_Discard(VRT_CTX, const char *);
+void VRT_VCL_Allow_Discard(struct vclref **);
void VRT_priv_fini(const struct vmod_priv *p);
struct vmod_priv *VRT_priv_task(VRT_CTX, const void *vmod_id);
diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c
index e2fef3125..1e6d06078 100644
--- a/lib/libvmod_debug/vmod_debug.c
+++ b/lib/libvmod_debug/vmod_debug.c
@@ -47,7 +47,6 @@ struct priv_vcl {
#define PRIV_VCL_MAGIC 0x8E62FA9D
char *foo;
uintptr_t obj_cb;
- struct vcl *vcl;
struct vclref *vclref;
};
@@ -341,7 +340,6 @@ priv_vcl_free(void *priv)
ObjUnsubscribeEvents(&priv_vcl->obj_cb);
VSL(SLT_Debug, 0, "Unsubscribed from Object Events");
}
- AZ(priv_vcl->vcl);
AZ(priv_vcl->vclref);
FREE_OBJ(priv_vcl);
AZ(priv_vcl);
@@ -393,31 +391,23 @@ event_warm(VRT_CTX, const struct vmod_priv *priv)
}
CAST_OBJ_NOTNULL(priv_vcl, priv->priv, PRIV_VCL_MAGIC);
- AZ(priv_vcl->vcl);
AZ(priv_vcl->vclref);
bprintf(buf, "vmod-debug ref on %s", VCL_Name(ctx->vcl));
- priv_vcl->vcl = ctx->vcl;
- priv_vcl->vclref = VRT_ref_vcl(ctx, buf);
+ priv_vcl->vclref = VRT_VCL_Prevent_Discard(ctx, buf);
return (0);
}
static void*
cooldown_thread(void *priv)
{
- struct vrt_ctx ctx;
struct priv_vcl *priv_vcl;
CAST_OBJ_NOTNULL(priv_vcl, priv, PRIV_VCL_MAGIC);
- AN(priv_vcl->vcl);
AN(priv_vcl->vclref);
- INIT_OBJ(&ctx, VRT_CTX_MAGIC);
- ctx.vcl = priv_vcl->vcl;
-
VTIM_sleep(vcl_release_delay);
- VRT_rel_vcl(&ctx, &priv_vcl->vclref);
- priv_vcl->vcl = NULL;
+ VRT_VCL_Allow_Discard(&priv_vcl->vclref);
return (NULL);
}
@@ -428,14 +418,12 @@ event_cold(VRT_CTX, const struct vmod_priv *priv)
struct priv_vcl *priv_vcl;
CAST_OBJ_NOTNULL(priv_vcl, priv->priv, PRIV_VCL_MAGIC);
- AN(priv_vcl->vcl);
AN(priv_vcl->vclref);
VSL(SLT_Debug, 0, "%s: VCL_EVENT_COLD", VCL_Name(ctx->vcl));
if (vcl_release_delay == 0.0) {
- VRT_rel_vcl(ctx, &priv_vcl->vclref);
- priv_vcl->vcl = NULL;
+ VRT_VCL_Allow_Discard(&priv_vcl->vclref);
return (0);
}
More information about the varnish-commit
mailing list