[master] f367c79 Crude hack to try to get a clue to why rdlocks are unhappy on certain platforms

Poul-Henning Kamp phk at FreeBSD.org
Sat Sep 10 16:06:09 CEST 2016


commit f367c790f85402068ca02202732fb3ebc9f38f4d
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Sat Sep 10 14:05:11 2016 +0000

    Crude hack to try to get a clue to why rdlocks are unhappy on certain
    platforms

diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index 3cb2b69..621711c 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -30,6 +30,7 @@
 
 #include "config.h"
 
+#include <errno.h>
 #include <dlfcn.h>
 #include <pthread.h>
 #include <stdio.h>
@@ -252,9 +253,9 @@ vcl_get(struct vcl **vcc, struct vcl *vcl)
 {
 
 	CHECK_OBJ_NOTNULL(vcl, VCL_MAGIC);
-	AZ(pthread_rwlock_rdlock(&vcl->temp_rwl));
+	AZ(errno=pthread_rwlock_rdlock(&vcl->temp_rwl));
 	assert(VCL_WARM(vcl));
-	AZ(pthread_rwlock_unlock(&vcl->temp_rwl));
+	AZ(errno=pthread_rwlock_unlock(&vcl->temp_rwl));
 	Lck_Lock(&vcl_mtx);
 	AN(vcl);
 	if (vcl->label == NULL)
@@ -294,9 +295,9 @@ VCL_Ref(struct vcl *vcl)
 {
 
 	CHECK_OBJ_NOTNULL(vcl, VCL_MAGIC);
-	AZ(pthread_rwlock_rdlock(&vcl->temp_rwl));
+	AZ(errno=pthread_rwlock_rdlock(&vcl->temp_rwl));
 	assert(!VCL_COLD(vcl));
-	AZ(pthread_rwlock_unlock(&vcl->temp_rwl));
+	AZ(errno=pthread_rwlock_unlock(&vcl->temp_rwl));
 	Lck_Lock(&vcl_mtx);
 	assert(vcl->busy > 0);
 	vcl->busy++;
@@ -332,9 +333,9 @@ VCL_AddBackend(struct vcl *vcl, struct backend *be)
 	CHECK_OBJ_NOTNULL(vcl, VCL_MAGIC);
 	CHECK_OBJ_NOTNULL(be, BACKEND_MAGIC);
 
-	AZ(pthread_rwlock_rdlock(&vcl->temp_rwl));
+	AZ(errno=pthread_rwlock_rdlock(&vcl->temp_rwl));
 	if (vcl->temp == VCL_TEMP_COOLING) {
-		AZ(pthread_rwlock_unlock(&vcl->temp_rwl));
+		AZ(errno=pthread_rwlock_unlock(&vcl->temp_rwl));
 		return (1);
 	}
 
@@ -347,7 +348,7 @@ VCL_AddBackend(struct vcl *vcl, struct backend *be)
 		VBE_Event(be, VCL_EVENT_WARM);
 	else if (vcl->temp != VCL_TEMP_INIT)
 		WRONG("Dynamic Backends can only be added to warm VCLs");
-	AZ(pthread_rwlock_unlock(&vcl->temp_rwl));
+	AZ(errno=pthread_rwlock_unlock(&vcl->temp_rwl));
 
 	return (0);
 }
@@ -364,10 +365,10 @@ VCL_DelBackend(struct backend *be)
 	VTAILQ_REMOVE(&vcl->backend_list, be, vcl_list);
 	Lck_Unlock(&vcl_mtx);
 
-	AZ(pthread_rwlock_rdlock(&vcl->temp_rwl));
+	AZ(errno=pthread_rwlock_rdlock(&vcl->temp_rwl));
 	if (VCL_WARM(vcl))
 		VBE_Event(be, VCL_EVENT_COLD);
-	AZ(pthread_rwlock_unlock(&vcl->temp_rwl));
+	AZ(errno=pthread_rwlock_unlock(&vcl->temp_rwl));
 }
 
 static void
@@ -436,7 +437,7 @@ VCL_Open(const char *fn, struct vsb *msg)
 	}
 	ALLOC_OBJ(vcl, VCL_MAGIC);
 	AN(vcl);
-	AZ(pthread_rwlock_init(&vcl->temp_rwl, NULL));
+	AZ(errno=pthread_rwlock_init(&vcl->temp_rwl, NULL));
 	vcl->dlh = dlh;
 	vcl->conf = cnf;
 	return (vcl);
@@ -451,7 +452,7 @@ VCL_Close(struct vcl **vclp)
 	vcl = *vclp;
 	*vclp = NULL;
 	AZ(dlclose(vcl->dlh));
-	AZ(pthread_rwlock_destroy(&vcl->temp_rwl));
+	AZ(errno=pthread_rwlock_destroy(&vcl->temp_rwl));
 	FREE_OBJ(vcl);
 }
 
@@ -641,7 +642,7 @@ vcl_set_state(VRT_CTX, const char *state)
 	assert(ctx->msg != NULL || *state == '0');
 
 	vcl = ctx->vcl;
-	AZ(pthread_rwlock_wrlock(&vcl->temp_rwl));
+	AZ(errno=pthread_rwlock_wrlock(&vcl->temp_rwl));
 	AN(vcl->temp);
 
 	switch(state[0]) {
@@ -683,7 +684,7 @@ vcl_set_state(VRT_CTX, const char *state)
 	default:
 		WRONG("Wrong enum state");
 	}
-	AZ(pthread_rwlock_unlock(&vcl->temp_rwl));
+	AZ(errno=pthread_rwlock_unlock(&vcl->temp_rwl));
 
 	return (i);
 }



More information about the varnish-commit mailing list