From 005ce97b0bb396fbc19cedd6ffe981b3826d5c54 Mon Sep 17 00:00:00 2001 From: phk Date: Mon, 11 Sep 2006 12:00:50 +0000 Subject: [PATCH] Embellish the mutex debugging a bit git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@964 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index a6df67c3..2e7c99b6 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -441,6 +441,24 @@ int RFC2616_cache_policy(struct sess *sp, struct http *hp); #define LOCK(foo) AZ(pthread_mutex_lock(foo)) #define UNLOCK(foo) AZ(pthread_mutex_unlock(foo)) #else -#define LOCK(foo) do { AZ(pthread_mutex_lock(foo)); VSL(SLT_Debug, 0, "LOCK(%s,%s,%d," #foo ")", __func__, __FILE__, __LINE__); } while (0); -#define UNLOCK(foo) do { AZ(pthread_mutex_unlock(foo)); VSL(SLT_Debug, 0, "UNLOC(%s,%s,%d," #foo ")", __func__, __FILE__, __LINE__); } while (0); +#define LOCK(foo) \ +do { \ + if (pthread_mutex_trylock(foo)) { \ + VSL(SLT_Debug, 0, \ + "MTX_CONTEST(%s,%s,%d," #foo ")", \ + __func__, __FILE__, __LINE__); \ + AZ(pthread_mutex_lock(foo)); \ + } else { \ + VSL(SLT_Debug, 0, \ + "MTXLOCK(%s,%s,%d," #foo ")", \ + __func__, __FILE__, __LINE__); \ + } \ +} while (0); +#define UNLOCK(foo) \ +do { \ + AZ(pthread_mutex_unlock(foo)); \ + VSL(SLT_Debug, 0, \ + "MTX_UNLOCK(%s,%s,%d," #foo ")", \ + __func__, __FILE__, __LINE__); \ +} while (0); #endif -- 2.39.5