• Dridi Boukelmoune's avatar
    Make VMODs actually fail warm-ups · 36293d0d
    Dridi Boukelmoune authored
    The implementation is similar to the load/discard dance when a load
    fails. New VGC functions are introduced iff the VCL has at least one
    VMOD handling events.
    
    The generated code looks like this:
    
    	static unsigned vgc_inistep;
    	static unsigned vgc_warmupstep;
    
    	...
    
    	static int
    	VGC_Load(VRT_CTX)
    	{
    		...
    	}
    
    	static int
    	VGC_Discard(VRT_CTX)
    	{
    		...
    	}
    
    	static int
    	VGC_Warmup(VRT_CTX, enum vcl_event_e ev)
    	{
    
    		vgc_warmupstep = 0;
    
    		/* 4 */
    		if (Vmod_debug_Func._event(ctx, &vmod_priv_debug, ev))
    			return (1);
    		vgc_warmupstep = 4;
    
    		return (0);
    	}
    
    	static int
    	VGC_Use(VRT_CTX, enum vcl_event_e ev)
    	{
    
    		/* 4 */
    		if (Vmod_debug_Func._event(ctx, &vmod_priv_debug, ev))
    			return (1);
    
    		return (0);
    	}
    
    	static int
    	VGC_Cooldown(VRT_CTX, enum vcl_event_e ev)
    	{
    		int retval = 0;
    
    		/* 4 */
    		if (vgc_warmupstep >= 4 &&
    		    Vmod_debug_Func._event(ctx, &vmod_priv_debug, ev) != 0)
    			retval = 1;
    
    		return (retval);
    	}
    
    	static int
    	VGC_Event(VRT_CTX, enum vcl_event_e ev)
    	{
    		if (ev == VCL_EVENT_LOAD)
    			return(VGC_Load(ctx));
    		if (ev == VCL_EVENT_WARM)
    			return(VGC_Warmup(ctx, ev));
    		if (ev == VCL_EVENT_USE)
    			return(VGC_Use(ctx, ev));
    		if (ev == VCL_EVENT_COLD)
    			return(VGC_Cooldown(ctx, ev));
    		if (ev == VCL_EVENT_DISCARD)
    			return(VGC_Discard(ctx));
    
    		return (1);
    	}
    
    However, if there are no VMODs handling events, no new functions shall
    be generated, leading to code looking like this:
    
    	static unsigned vgc_inistep;
    	static unsigned vgc_warmupstep;
    
    	...
    
    	static int
    	VGC_Load(VRT_CTX)
    	{
    		...
    	}
    
    	static int
    	VGC_Discard(VRT_CTX)
    	{
    		...
    	}
    
    	static int
    	VGC_Event(VRT_CTX, enum vcl_event_e ev)
    	{
    		if (ev == VCL_EVENT_LOAD)
    			return(VGC_Load(ctx));
    		if (ev == VCL_EVENT_DISCARD)
    			return(VGC_Discard(ctx));
    
    		(void)vgc_warmupstep;
    		return (0);
    	}
    36293d0d
Name
Last commit
Last update
..
Makefile.am Loading commit data...
Makefile.phk Loading commit data...
flint.lnt Loading commit data...
flint.sh Loading commit data...
generate.py Loading commit data...
vcc_acl.c Loading commit data...
vcc_action.c Loading commit data...
vcc_backend.c Loading commit data...
vcc_backend_util.c Loading commit data...
vcc_compile.c Loading commit data...
vcc_compile.h Loading commit data...
vcc_expr.c Loading commit data...
vcc_parse.c Loading commit data...
vcc_storage.c Loading commit data...
vcc_symb.c Loading commit data...
vcc_token.c Loading commit data...
vcc_utils.c Loading commit data...
vcc_var.c Loading commit data...
vcc_vmod.c Loading commit data...
vcc_xref.c Loading commit data...
vmodtool.py Loading commit data...