[master] 09628c7 Propagate warm/cold transitions to VCL_EVENTs

Poul-Henning Kamp phk at FreeBSD.org
Mon Mar 9 11:49:35 CET 2015


commit 09628c73d2c2e6ff0ee9bad424d4f554a3819e54
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Mar 9 10:34:04 2015 +0000

    Propagate warm/cold transitions to VCL_EVENTs

diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index 0db8cd8..a5a7da4 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -172,9 +172,22 @@ vcl_find(const char *name)
 static void
 vcl_set_state(struct vcls *vcl, const char *state)
 {
+	struct vrt_ctx ctx;
+	int warm;
+	unsigned hand = 0;
 
-	vcl->warm = state[0] == '1' ? 1 : 0;
+	assert(state[0] == '0' || state[0] == '1');
+	warm = state[0] == '1' ? 1 : 0;
 	bprintf(vcl->state, "%s", state + 1);
+	if (warm == vcl->warm)
+		return;
+
+	vcl->warm = warm;
+
+	INIT_OBJ(&ctx, VRT_CTX_MAGIC);
+	ctx.handling = &hand;
+	(void)vcl->conf->event_vcl(&ctx,
+	    vcl->warm ? VCL_EVENT_WARM : VCL_EVENT_COLD);
 }
 
 static int
@@ -384,6 +397,7 @@ ccf_config_use(struct cli *cli, const char * const *av, void *priv)
 	AZ(priv);
 	vcl = vcl_find(av[2]);
 	AN(vcl);			// MGT ensures this
+	AN(vcl->warm);			// MGT ensures this
 	INIT_OBJ(&ctx, VRT_CTX_MAGIC);
 	ctx.handling = &hand;
 	ctx.cli = cli;



More information about the varnish-commit mailing list