Commit 28eec51b authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

Make event handling more readable in vmod-debug

parent 57a5b9c7
......@@ -249,23 +249,10 @@ priv_vcl_free(void *priv)
AZ(priv_vcl);
}
int __match_proto__(vmod_event_f)
event_function(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e)
static int
event_load(VRT_CTX, struct vmod_priv *priv)
{
struct priv_vcl *priv_vcl;
const char *ev;
switch (e) {
case VCL_EVENT_COLD: ev = "VCL_EVENT_COLD"; break;
case VCL_EVENT_WARM: ev = "VCL_EVENT_WARM"; break;
default: ev = NULL;
}
if (ev != NULL)
VSL(SLT_Debug, 0, "%s: %s", VCL_Name(ctx->vcl), ev);
if (e != VCL_EVENT_LOAD)
return (0);
AN(ctx->msg);
if (cache_param->nuke_limit == 42) {
......@@ -282,6 +269,40 @@ event_function(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e)
return (0);
}
static int
event_warm(VRT_CTX)
{
VSL(SLT_Debug, 0, "%s: VCL_EVENT_WARM", VCL_Name(ctx->vcl));
if (cache_param->max_esi_depth == 42) {
VSB_printf(ctx->msg, "max_esi_depth is not the answer.");
return (-1);
}
return (0);
}
static int
event_cold(VRT_CTX)
{
VSL(SLT_Debug, 0, "%s: VCL_EVENT_COLD", VCL_Name(ctx->vcl));
return (0);
}
int __match_proto__(vmod_event_f)
event_function(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e)
{
switch (e) {
case VCL_EVENT_LOAD: return event_load(ctx, priv);
case VCL_EVENT_COLD: return event_cold(ctx);
case VCL_EVENT_WARM: return event_warm(ctx);
default: return (0);
}
}
VCL_VOID __match_proto__(td_debug_sleep)
vmod_sleep(VRT_CTX, VCL_DURATION t)
{
......
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