Commit 5df6f8d4 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Change VRT_re[fl]_vcl() to VRT_VCL_{Prevent|Allow}_Discard()

parent d7a81fe8
......@@ -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];
};
......
......@@ -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
......
......@@ -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);
......
......@@ -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);
}
......
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