[master] 09939bc Check return from pthread_mutex_trylock()

Poul-Henning Kamp phk at varnish-cache.org
Fri Jan 25 10:04:48 CET 2013


commit 09939bc49fabaaedb40506eb994a35169d72086d
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Fri Jan 25 09:04:31 2013 +0000

    Check return from pthread_mutex_trylock()

diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c
index 060773b..198e225 100644
--- a/bin/varnishd/cache/cache_shmlog.c
+++ b/bin/varnishd/cache/cache_shmlog.c
@@ -115,10 +115,14 @@ static uint32_t *
 vsl_get(unsigned len, unsigned records, unsigned flushes)
 {
 	uint32_t *p;
+	int err;
 
-	if (pthread_mutex_trylock(&vsl_mtx)) {
+	err = pthread_mutex_trylock(&vsl_mtx);
+	if (err == EBUSY) {
 		AZ(pthread_mutex_lock(&vsl_mtx));
 		VSC_C_main->shm_cont++;
+	} else {
+		AZ(err);
 	}
 	assert(vsl_ptr < vsl_end);
 	assert(((uintptr_t)vsl_ptr & 0x3) == 0);



More information about the varnish-commit mailing list