Commit 54908ac1 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Duh! Last committed from wrong directory.

parent 1d0298e1
......@@ -10,9 +10,9 @@ varnish v1 -vcl+backend {
sub vcl_recv {
if (req.url == "/hold") {
debug.hold_vcl_busy();
debug.vcl_prevent_cold();
} else if (req.url == "/release") {
debug.release_vcl_busy();
debug.vcl_allow_cold();
}
return (synth(200));
}
......
......@@ -6,7 +6,7 @@ server s1 -start
varnish v1 -vcl+backend {
import debug;
sub vcl_init {
debug.vcl_release_delay(3s);
debug.vcl_discard_delay(3s);
}
} -start
......
......@@ -52,10 +52,11 @@
* binary/load-time compatible, increment MAJOR version
*
* unreleased (planned for 2019-09-15)
* VRT_VCL_{Busy|Unbusy} changed to VRT_VCL_{Prevent|Allow}_Cold
* 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.
* VRT_VCL_Prevent_Cold() and VRT_VCL_Allow_Cold() added.
* VRT_vcl_get moved to vcc_interface.h
* VRT_vcl_rel emoved to vcc_interface.h
* VRT_vcl_select emoved to vcc_interface.h
......@@ -523,10 +524,6 @@ struct vmod_priv {
vmod_priv_free_f *free;
};
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);
struct vmod_priv *VRT_priv_top(VRT_CTX, const void *vmod_id);
......@@ -563,8 +560,12 @@ void VRT_VSC_Reveal(const struct vsc_seg *);
size_t VRT_VSC_Overhead(size_t);
/*
* API to prevent VCL from going cold
* API to restrict the VCL in various ways
*/
void VRT_VCL_Busy(VRT_CTX);
void VRT_VCL_Unbusy(VRT_CTX);
struct vclref;
struct vclref * VRT_VCL_Prevent_Cold(VRT_CTX, const char *);
void VRT_VCL_Allow_Cold(struct vclref **);
struct vclref * VRT_VCL_Prevent_Discard(VRT_CTX, const char *);
void VRT_VCL_Allow_Discard(struct vclref **);
......@@ -160,9 +160,10 @@ $Method VOID .refresh(STRING path)
Dynamically refresh & (always!) replace the backend by a new UDS backend.
$Function VOID vcl_release_delay(DURATION)
$Function VOID vcl_discard_delay(PRIV_VCL, DURATION)
Hold a reference to the VCL when it goes cold for the given delay.
Hold a reference to the VCL when it goes cold preventing
discard for the given delay.
$Function BOOL match_acl(ACL acl, IP ip)
......@@ -244,11 +245,11 @@ should now only be used for diagnostic purposes.
0B is returned if no sensible value can be determined.
$Function VOID hold_vcl_busy()
$Function VOID vcl_prevent_cold(PRIV_VCL)
Prevent VCL from going cold
$Function VOID release_vcl_busy()
$Function VOID vcl_allow_cold(PRIV_VCL)
Allow VCL to go cold
......
......@@ -47,10 +47,11 @@ struct priv_vcl {
#define PRIV_VCL_MAGIC 0x8E62FA9D
char *foo;
uintptr_t obj_cb;
struct vclref *vclref;
struct vclref *vclref_discard;
struct vclref *vclref_cold;
VCL_DURATION vcl_discard_delay;
};
static VCL_DURATION vcl_release_delay = 0.0;
static pthread_mutex_t vsc_mtx = PTHREAD_MUTEX_INITIALIZER;
static struct vsc_seg *vsc_seg = NULL;
......@@ -340,7 +341,8 @@ priv_vcl_free(void *priv)
ObjUnsubscribeEvents(&priv_vcl->obj_cb);
VSL(SLT_Debug, 0, "Unsubscribed from Object Events");
}
AZ(priv_vcl->vclref);
AZ(priv_vcl->vclref_discard);
AZ(priv_vcl->vclref_cold);
FREE_OBJ(priv_vcl);
AZ(priv_vcl);
}
......@@ -376,6 +378,32 @@ event_load(VRT_CTX, struct vmod_priv *priv)
return (0);
}
VCL_VOID
xyzzy_vcl_prevent_cold(VRT_CTX, struct vmod_priv *priv)
{
struct priv_vcl *priv_vcl;
char buf[32];
CAST_OBJ_NOTNULL(priv_vcl, priv->priv, PRIV_VCL_MAGIC);
AZ(priv_vcl->vclref_cold);
bprintf(buf, "vmod-debug ref on %s", VCL_Name(ctx->vcl));
priv_vcl->vclref_cold = VRT_VCL_Prevent_Cold(ctx, buf);
}
VCL_VOID
xyzzy_vcl_allow_cold(VRT_CTX, struct vmod_priv *priv)
{
struct priv_vcl *priv_vcl;
(void)ctx;
CAST_OBJ_NOTNULL(priv_vcl, priv->priv, PRIV_VCL_MAGIC);
AN(priv_vcl->vclref_cold);
VRT_VCL_Allow_Cold(&priv_vcl->vclref_cold);
}
static int
event_warm(VRT_CTX, const struct vmod_priv *priv)
{
......@@ -391,10 +419,10 @@ event_warm(VRT_CTX, const struct vmod_priv *priv)
}
CAST_OBJ_NOTNULL(priv_vcl, priv->priv, PRIV_VCL_MAGIC);
AZ(priv_vcl->vclref);
AZ(priv_vcl->vclref_discard);
bprintf(buf, "vmod-debug ref on %s", VCL_Name(ctx->vcl));
priv_vcl->vclref = VRT_VCL_Prevent_Discard(ctx, buf);
priv_vcl->vclref_discard = VRT_VCL_Prevent_Discard(ctx, buf);
return (0);
}
......@@ -404,10 +432,10 @@ cooldown_thread(void *priv)
struct priv_vcl *priv_vcl;
CAST_OBJ_NOTNULL(priv_vcl, priv, PRIV_VCL_MAGIC);
AN(priv_vcl->vclref);
AN(priv_vcl->vclref_discard);
VTIM_sleep(vcl_release_delay);
VRT_VCL_Allow_Discard(&priv_vcl->vclref);
VTIM_sleep(priv_vcl->vcl_discard_delay);
VRT_VCL_Allow_Discard(&priv_vcl->vclref_discard);
return (NULL);
}
......@@ -418,12 +446,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->vclref);
AN(priv_vcl->vclref_discard);
VSL(SLT_Debug, 0, "%s: VCL_EVENT_COLD", VCL_Name(ctx->vcl));
if (vcl_release_delay == 0.0) {
VRT_VCL_Allow_Discard(&priv_vcl->vclref);
if (priv_vcl->vcl_discard_delay == 0.0) {
VRT_VCL_Allow_Discard(&priv_vcl->vclref_discard);
return (0);
}
......@@ -469,13 +497,15 @@ xyzzy_event_function(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e)
}
}
VCL_VOID v_matchproto_(td_debug_vcl_release_delay)
xyzzy_vcl_release_delay(VRT_CTX, VCL_DURATION delay)
VCL_VOID v_matchproto_(td_debug_vcl_discard_delay)
xyzzy_vcl_discard_delay(VRT_CTX, struct vmod_priv *priv, VCL_DURATION delay)
{
struct priv_vcl *priv_vcl;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CAST_OBJ_NOTNULL(priv_vcl, priv->priv, PRIV_VCL_MAGIC);
assert(delay > 0.0);
vcl_release_delay = delay;
priv_vcl->vcl_discard_delay = delay;
}
VCL_BOOL v_matchproto_(td_debug_match_acl)
......@@ -782,20 +812,6 @@ xyzzy_stk(VRT_CTX)
return (0);
}
VCL_VOID
xyzzy_hold_vcl_busy(VRT_CTX)
{
VRT_VCL_Busy(ctx);
}
VCL_VOID
xyzzy_release_vcl_busy(VRT_CTX)
{
VRT_VCL_Unbusy(ctx);
}
VCL_VOID
xyzzy_sndbuf(VRT_CTX, VCL_BYTES arg)
{
......
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