]> err.no Git - varnish/commitdiff
Embellish the mutex debugging a bit
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 11 Sep 2006 12:00:50 +0000 (12:00 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 11 Sep 2006 12:00:50 +0000 (12:00 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@964 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache.h

index a6df67c37ff39e8fe6a9c61edca3381053beff62..2e7c99b6c613edd09889094967e11ddb661974fe 100644 (file)
@@ -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