[master] 025f4dac9 change vcl temperature macros from vcl to temperature argument

Nils Goroll nils.goroll at uplex.de
Mon Nov 18 15:05:07 UTC 2019


commit 025f4dac952afd40f7d22ab2de8bc4d953c95970
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Wed Nov 13 16:18:48 2019 +0100

    change vcl temperature macros from vcl to temperature argument
    
    we are going to need to check a temperature on its own

diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 328e9078b..402f9f6f4 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -604,7 +604,7 @@ VRT_new_backend_clustered(VRT_CTX, struct vsmw_cluster *vc,
 
 	if (be->director != NULL) {
 		/* for cold VCL, update initial director state */
-		if (be->probe != NULL && ! VCL_WARM(vcl))
+		if (be->probe != NULL && ! VCL_WARM(vcl->temp))
 			VBP_Update_Backend(be->probe);
 
 		Lck_Lock(&backends_mtx);
diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index 721622738..bdff0e489 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -265,7 +265,7 @@ vcl_get(struct vcl **vcc, struct vcl *vcl)
 	(*vcc)->busy++;
 	Lck_Unlock(&vcl_mtx);
 	AZ(errno=pthread_rwlock_rdlock(&(*vcc)->temp_rwl));
-	assert(VCL_WARM(*vcc));
+	assert(VCL_WARM((*vcc)->temp));
 	AZ(errno=pthread_rwlock_unlock(&(*vcc)->temp_rwl));
 }
 
@@ -503,7 +503,7 @@ vcl_set_state(VRT_CTX, const char *state)
 	case '0':
 		if (vcl->temp == VCL_TEMP_COLD)
 			break;
-		if (vcl->busy == 0 && VCL_WARM(vcl)) {
+		if (vcl->busy == 0 && VCL_WARM(vcl->temp)) {
 			vcl->temp = VTAILQ_EMPTY(&vcl->ref_list) ?
 			    VCL_TEMP_COLD : VCL_TEMP_COOLING;
 			AZ(vcl_send_event(ctx, VCL_EVENT_COLD));
diff --git a/bin/varnishd/cache/cache_vcl.h b/bin/varnishd/cache/cache_vcl.h
index ac01706e2..cfe489956 100644
--- a/bin/varnishd/cache/cache_vcl.h
+++ b/bin/varnishd/cache/cache_vcl.h
@@ -80,7 +80,5 @@ extern const char * const VCL_TEMP_COOLING;
  * NB: The COOLING temperature is neither COLD nor WARM.
  * And LABEL is not a temperature, it's a different kind of VCL.
  */
-#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)
-
-
+#define VCL_WARM(t) ((t) == VCL_TEMP_WARM || (t) == VCL_TEMP_BUSY)
+#define VCL_COLD(t) ((t) == VCL_TEMP_INIT || (t) == VCL_TEMP_COLD)
diff --git a/bin/varnishd/cache/cache_vrt_vcl.c b/bin/varnishd/cache/cache_vrt_vcl.c
index a660c23e2..9356bceec 100644
--- a/bin/varnishd/cache/cache_vrt_vcl.c
+++ b/bin/varnishd/cache/cache_vrt_vcl.c
@@ -112,7 +112,7 @@ VCL_Ref(struct vcl *vcl)
 
 	CHECK_OBJ_NOTNULL(vcl, VCL_MAGIC);
 	AZ(errno=pthread_rwlock_rdlock(&vcl->temp_rwl));
-	assert(!VCL_COLD(vcl));
+	assert(!VCL_COLD(vcl->temp));
 	AZ(errno=pthread_rwlock_unlock(&vcl->temp_rwl));
 	Lck_Lock(&vcl_mtx);
 	assert(vcl->busy > 0);
@@ -193,7 +193,7 @@ VRT_AddDirector(VRT_CTX, const struct vdi_methods *m, void *priv,
 	VTAILQ_INSERT_TAIL(&vcl->director_list, vdir, list);
 	Lck_Unlock(&vcl_mtx);
 
-	if (VCL_WARM(vcl))
+	if (VCL_WARM(vcl->temp))
 		/* Only when adding backend to already warm VCL */
 		VDI_Event(d, VCL_EVENT_WARM);
 	else if (vcl->temp != VCL_TEMP_INIT)
@@ -220,7 +220,7 @@ VRT_DelDirector(VCL_BACKEND *bp)
 	Lck_Unlock(&vcl_mtx);
 
 	AZ(errno=pthread_rwlock_rdlock(&vcl->temp_rwl));
-	if (VCL_WARM(vcl))
+	if (VCL_WARM(vcl->temp))
 		VDI_Event(d, VCL_EVENT_COLD);
 	AZ(errno=pthread_rwlock_unlock(&vcl->temp_rwl));
 	if(vdir->methods->destroy != NULL)
@@ -363,7 +363,7 @@ VRT_VCL_Prevent_Discard(VRT_CTX, const char *desc)
 
 	vcl = ctx->vcl;
 	CHECK_OBJ_NOTNULL(vcl, VCL_MAGIC);
-	assert(VCL_WARM(vcl));
+	assert(VCL_WARM(vcl->temp));
 
 	ALLOC_OBJ(ref, VCLREF_MAGIC);
 	AN(ref);


More information about the varnish-commit mailing list