r2518 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Tue Feb 19 13:05:41 CET 2008


Author: phk
Date: 2008-02-19 13:05:41 +0100 (Tue, 19 Feb 2008)
New Revision: 2518

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/mgt_param.c
Log:
Make logging of mutex operations or just contests controlled under diag_bitmap


Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2008-02-19 12:00:47 UTC (rev 2517)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2008-02-19 12:05:41 UTC (rev 2518)
@@ -592,24 +592,19 @@
 /* rfc2616.c */
 int RFC2616_cache_policy(const struct sess *sp, const struct http *hp);
 
-#if 1
 #define MTX			pthread_mutex_t
 #define MTX_INIT(foo)		AZ(pthread_mutex_init(foo, NULL))
 #define MTX_DESTROY(foo)	AZ(pthread_mutex_destroy(foo))
-#define LOCK(foo)		AZ(pthread_mutex_lock(foo))
-#define UNLOCK(foo)		AZ(pthread_mutex_unlock(foo))
-#else
-#define MTX			pthread_mutex_t
-#define MTX_INIT(foo)		AZ(pthread_mutex_init(foo, NULL))
-#define MTX_DESTROY(foo)	AZ(pthread_mutex_destroy(foo))
 #define LOCK(foo) 					\
 do { 							\
-	if (pthread_mutex_trylock(foo)) {		\
+	if (!(params->diag_bitmap & 0x18)) {		\
+		AZ(pthread_mutex_lock(foo)); 		\
+	} else if (pthread_mutex_trylock(foo)) {	\
 		VSL(SLT_Debug, 0,			\
 		    "MTX_CONTEST(%s,%s,%d," #foo ")",	\
 		    __func__, __FILE__, __LINE__);	\
 		AZ(pthread_mutex_lock(foo)); 		\
-	} else if (1) {					\
+	} else if (params->diag_bitmap & 0x8) {		\
 		VSL(SLT_Debug, 0,			\
 		    "MTX_LOCK(%s,%s,%d," #foo ")",	\
 		    __func__, __FILE__, __LINE__); 	\
@@ -618,12 +613,11 @@
 #define UNLOCK(foo)					\
 do {							\
 	AZ(pthread_mutex_unlock(foo));			\
-	if (1)						\
+	if (params->diag_bitmap & 0x8)			\
 		VSL(SLT_Debug, 0,			\
 		    "MTX_UNLOCK(%s,%s,%d," #foo ")",	\
 		    __func__, __FILE__, __LINE__);	\
 } while (0);
-#endif
 
 #if defined(HAVE_PTHREAD_MUTEX_ISOWNED_NP)
 #define ALOCKED(mutex)		AN(pthread_mutex_isowned_np((mutex)))

Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_param.c	2008-02-19 12:00:47 UTC (rev 2517)
+++ trunk/varnish-cache/bin/varnishd/mgt_param.c	2008-02-19 12:05:41 UTC (rev 2518)
@@ -641,6 +641,8 @@
 		"  0x00000001 - CNT_Session states.\n"
 		"  0x00000002 - workspace debugging.\n"
 		"  0x00000004 - kqueue debugging.\n"
+		"  0x00000008 - mutex logging.\n"
+		"  0x00000010 - mutex contests.\n"
 		"Use 0x notation and do the bitor in your head :-)\n",
 		0,
 		"0", "bitmap" },




More information about the varnish-commit mailing list