[4.1] d255cde Clarify what makes a VCL warm or cold

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Mon Sep 12 17:57:13 CEST 2016


commit d255cde2c1303b646e27cd315bdea57be7fea07f
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Tue Aug 30 20:23:34 2016 +0200

    Clarify what makes a VCL warm or cold
    
    Conflicts:
    	bin/varnishd/cache/cache_vcl.c

diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index 37927f7..3a38bc4 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -53,6 +53,10 @@ static const char * const VCL_TEMP_WARM = "warm";
 static const char * const VCL_TEMP_BUSY = "busy";
 static const char * const VCL_TEMP_COOLING = "cooling";
 
+/* NB: The COOLING temperature is neither COLD nor WARM. */
+#define VCL_WARM(v) ((v)->temp == VCL_TEMP_WARM || (v)->temp == VCL_TEMP_BUSY)
+#define VCL_COLD(v) ((v)->temp == VCL_TEMP_INIT || (v)->temp == VCL_TEMP_COLD)
+
 struct vcl {
 	unsigned		magic;
 #define VCL_MAGIC		0x214188f2
@@ -159,7 +163,7 @@ VCL_Get(struct vcl **vcc)
 		(void)usleep(100000);
 
 	CHECK_OBJ_NOTNULL(vcl_active, VCL_MAGIC);
-	assert(vcl_active->temp == VCL_TEMP_WARM);
+	assert(VCL_WARM(vcl_active));
 	Lck_Lock(&vcl_mtx);
 	AN(vcl_active);
 	*vcc = vcl_active;
@@ -173,7 +177,7 @@ void
 VCL_Refresh(struct vcl **vcc)
 {
 	CHECK_OBJ_NOTNULL(vcl_active, VCL_MAGIC);
-	assert(vcl_active->temp == VCL_TEMP_WARM);
+	assert(VCL_WARM(vcl_active));
 	if (*vcc == vcl_active)
 		return;
 	if (*vcc != NULL)
@@ -186,7 +190,7 @@ VCL_Ref(struct vcl *vcl)
 {
 
 	CHECK_OBJ_NOTNULL(vcl, VCL_MAGIC);
-	assert(vcl->temp != VCL_TEMP_INIT && vcl->temp != VCL_TEMP_COLD);
+	assert(!VCL_COLD(vcl));
 	Lck_Lock(&vcl_mtx);
 	assert(vcl->busy > 0);
 	vcl->busy++;
@@ -229,7 +233,7 @@ VCL_AddBackend(struct vcl *vcl, struct backend *be)
 	VTAILQ_INSERT_TAIL(&vcl->backend_list, be, vcl_list);
 	Lck_Unlock(&vcl_mtx);
 
-	if (vcl->temp == VCL_TEMP_WARM || vcl->temp == VCL_TEMP_BUSY)
+	if (VCL_WARM(vcl))
 		/* Only when adding backend to already warm VCL */
 		VBE_Event(be, VCL_EVENT_WARM);
 	else if (vcl->temp != VCL_TEMP_INIT)
@@ -417,7 +421,7 @@ VRT_ref_vcl(VRT_CTX, const char *desc)
 
 	vcl = ctx->vcl;
 	CHECK_OBJ_NOTNULL(vcl, VCL_MAGIC);
-	xxxassert(vcl->temp == VCL_TEMP_WARM);
+	assert(VCL_WARM(vcl));
 
 	ALLOC_OBJ(ref, VCLREF_MAGIC);
 	AN(ref);
@@ -547,8 +551,7 @@ vcl_set_state(VRT_CTX, const char *state)
 	switch(state[0]) {
 	case '0':
 		assert(vcl->temp != VCL_TEMP_COLD);
-		if (vcl->busy == 0 && (vcl->temp == VCL_TEMP_WARM ||
-		    vcl->temp == VCL_TEMP_BUSY)) {
+		if (vcl->busy == 0 && VCL_WARM(vcl)) {
 
 			vcl->temp = VTAILQ_EMPTY(&vcl->ref_list) ?
 			    VCL_TEMP_COLD : VCL_TEMP_COOLING;



More information about the varnish-commit mailing list