r1029 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Sat Sep 16 17:54:57 CEST 2006


Author: phk
Date: 2006-09-16 17:54:56 +0200 (Sat, 16 Sep 2006)
New Revision: 1029

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_backend.c
   trunk/varnish-cache/bin/varnishd/cache_cli.c
   trunk/varnish-cache/bin/varnishd/cache_expire.c
   trunk/varnish-cache/bin/varnishd/cache_hash.c
   trunk/varnish-cache/bin/varnishd/cache_pool.c
   trunk/varnish-cache/bin/varnishd/cache_session.c
   trunk/varnish-cache/bin/varnishd/cache_vcl.c
   trunk/varnish-cache/bin/varnishd/hash_classic.c
   trunk/varnish-cache/bin/varnishd/hash_simple_list.c
   trunk/varnish-cache/bin/varnishd/shmlog.c
   trunk/varnish-cache/bin/varnishd/storage_file.c
Log:
Wrap mutex more completely so that experimentation becomes easier.


Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2006-09-16 15:52:53 UTC (rev 1028)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2006-09-16 15:54:56 UTC (rev 1029)
@@ -439,8 +439,11 @@
 #define UNLOCKSHM(foo)	AZ(pthread_mutex_unlock(foo))
 
 #if 1
-#define LOCK(foo)	AZ(pthread_mutex_lock(foo))
-#define UNLOCK(foo)	AZ(pthread_mutex_unlock(foo))
+#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 LOCK(foo) 					\
 do { 							\

Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend.c	2006-09-16 15:52:53 UTC (rev 1028)
+++ trunk/varnish-cache/bin/varnishd/cache_backend.c	2006-09-16 15:54:56 UTC (rev 1029)
@@ -29,7 +29,7 @@
 
 static TAILQ_HEAD(,vbe_conn) vbe_head = TAILQ_HEAD_INITIALIZER(vbe_head);
 
-static pthread_mutex_t	vbemtx;
+static MTX vbemtx;
 
 /*--------------------------------------------------------------------*/
 
@@ -293,5 +293,5 @@
 VBE_Init(void)
 {
 
-	AZ(pthread_mutex_init(&vbemtx, NULL));
+	MTX_INIT(&vbemtx);
 }

Modified: trunk/varnish-cache/bin/varnishd/cache_cli.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_cli.c	2006-09-16 15:52:53 UTC (rev 1028)
+++ trunk/varnish-cache/bin/varnishd/cache_cli.c	2006-09-16 15:54:56 UTC (rev 1029)
@@ -70,6 +70,7 @@
 	buf = malloc(lbuf);
 	XXXAN(buf);
 	nbuf = 0;
+	printf("CLI ready\n");
 	while (1) {
 		pfd[0].fd = heritage.fds[2];
 		pfd[0].events = POLLIN;

Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_expire.c	2006-09-16 15:52:53 UTC (rev 1028)
+++ trunk/varnish-cache/bin/varnishd/cache_expire.c	2006-09-16 15:54:56 UTC (rev 1029)
@@ -21,7 +21,7 @@
 
 static pthread_t exp_thread;
 static struct binheap *exp_heap;
-static pthread_mutex_t exp_mtx;
+static MTX exp_mtx;
 static unsigned expearly = 30;
 static TAILQ_HEAD(,object) exp_deathrow = TAILQ_HEAD_INITIALIZER(exp_deathrow);
 
@@ -181,7 +181,7 @@
 EXP_Init(void)
 {
 
-	AZ(pthread_mutex_init(&exp_mtx, NULL));
+	MTX_INIT(&exp_mtx);
 	exp_heap = binheap_new(NULL, object_cmp, object_update);
 	XXXAN(exp_heap);
 	AZ(pthread_create(&exp_thread, NULL, exp_prefetch, NULL));

Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_hash.c	2006-09-16 15:52:53 UTC (rev 1028)
+++ trunk/varnish-cache/bin/varnishd/cache_hash.c	2006-09-16 15:54:56 UTC (rev 1029)
@@ -60,7 +60,7 @@
 		XXXAN(w->nobjhead);
 		w->nobjhead->magic = OBJHEAD_MAGIC;
 		TAILQ_INIT(&w->nobjhead->objects);
-		AZ(pthread_mutex_init(&w->nobjhead->mtx, NULL));
+		MTX_INIT(&w->nobjhead->mtx);
 		VSL_stats->n_objecthead++;
 	} else
 		CHECK_OBJ_NOTNULL(w->nobjhead, OBJHEAD_MAGIC);
@@ -209,7 +209,7 @@
 	if (hash->deref(oh))
 		return;
 	assert(TAILQ_EMPTY(&oh->objects));
-	AZ(pthread_mutex_destroy(&oh->mtx));
+	MTX_DESTROY(&oh->mtx);
 	VSL_stats->n_objecthead--;
 	free(oh);
 }

Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c	2006-09-16 15:52:53 UTC (rev 1028)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c	2006-09-16 15:54:56 UTC (rev 1029)
@@ -29,7 +29,7 @@
 #include "cli_priv.h"
 #include "cache.h"
 
-static pthread_mutex_t wrk_mtx;
+static MTX wrk_mtx;
 
 /* Number of work requests queued in excess of worker threads available */
 static unsigned		wrk_overflow;
@@ -312,7 +312,7 @@
 	pthread_t tp;
 	int i;
 
-	AZ(pthread_mutex_init(&wrk_mtx, NULL));
+	MTX_INIT(&wrk_mtx);
 
 	AZ(pthread_create(&tp, NULL, wrk_reaperthread, NULL));
 	AZ(pthread_detach(tp));

Modified: trunk/varnish-cache/bin/varnishd/cache_session.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_session.c	2006-09-16 15:52:53 UTC (rev 1028)
+++ trunk/varnish-cache/bin/varnishd/cache_session.c	2006-09-16 15:54:56 UTC (rev 1029)
@@ -57,9 +57,9 @@
 
 TAILQ_HEAD(srcaddrhead ,srcaddr);
 static struct srcaddrhead	srcaddr_hash[CLIENT_HASH];
-static pthread_mutex_t		ses_mtx;
-static pthread_mutex_t		stat_mtx;
-static pthread_mutex_t		ses_mem_mtx;
+static MTX			ses_mtx;
+static MTX			stat_mtx;
+static MTX			ses_mem_mtx;
 
 /*--------------------------------------------------------------------
  * Assign a srcaddr to this session.
@@ -288,7 +288,7 @@
 
 	for (i = 0; i < CLIENT_HASH; i++)
 		TAILQ_INIT(&srcaddr_hash[i]);
-	AZ(pthread_mutex_init(&ses_mtx, NULL));
-	AZ(pthread_mutex_init(&stat_mtx, NULL));
-	AZ(pthread_mutex_init(&ses_mem_mtx, NULL));
+	MTX_INIT(&ses_mtx);
+	MTX_INIT(&stat_mtx);
+	MTX_INIT(&ses_mem_mtx);
 }

Modified: trunk/varnish-cache/bin/varnishd/cache_vcl.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vcl.c	2006-09-16 15:52:53 UTC (rev 1028)
+++ trunk/varnish-cache/bin/varnishd/cache_vcl.c	2006-09-16 15:54:56 UTC (rev 1029)
@@ -37,7 +37,7 @@
 
 static struct vcls		*vcl_active; /* protected by vcl_mtx */
 
-static pthread_mutex_t		vcl_mtx;
+static MTX			vcl_mtx;
 
 /*--------------------------------------------------------------------*/
 
@@ -284,5 +284,5 @@
 VCL_Init()
 {
 
-	AZ(pthread_mutex_init(&vcl_mtx, NULL));
+	MTX_INIT(&vcl_mtx);
 }

Modified: trunk/varnish-cache/bin/varnishd/hash_classic.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/hash_classic.c	2006-09-16 15:52:53 UTC (rev 1028)
+++ trunk/varnish-cache/bin/varnishd/hash_classic.c	2006-09-16 15:54:56 UTC (rev 1029)
@@ -31,7 +31,7 @@
 	unsigned		magic;
 #define HCL_HEAD_MAGIC		0x0f327016
 	TAILQ_HEAD(, hcl_entry)	head;
-	pthread_mutex_t		mtx;
+	MTX			mtx;
 };
 
 static unsigned			hcl_nhash = 16383;
@@ -79,7 +79,7 @@
 
 	for (u = 0; u < hcl_nhash; u++) {
 		TAILQ_INIT(&hcl_head[u].head);
-		AZ(pthread_mutex_init(&hcl_head[u].mtx, NULL));
+		MTX_INIT(&hcl_head[u].mtx);
 		hcl_head[u].magic = HCL_HEAD_MAGIC;
 	}
 }

Modified: trunk/varnish-cache/bin/varnishd/hash_simple_list.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/hash_simple_list.c	2006-09-16 15:52:53 UTC (rev 1028)
+++ trunk/varnish-cache/bin/varnishd/hash_simple_list.c	2006-09-16 15:54:56 UTC (rev 1029)
@@ -22,7 +22,7 @@
 };
 
 static TAILQ_HEAD(, hsl_entry)	hsl_head = TAILQ_HEAD_INITIALIZER(hsl_head);
-static pthread_mutex_t hsl_mutex;
+static MTX hsl_mutex;
 
 /*--------------------------------------------------------------------
  * The ->init method is called during process start and allows 
@@ -33,7 +33,7 @@
 hsl_start(void)
 {
 
-	AZ(pthread_mutex_init(&hsl_mutex, NULL));
+	MTX_INIT(&hsl_mutex);
 }
 
 /*--------------------------------------------------------------------

Modified: trunk/varnish-cache/bin/varnishd/shmlog.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/shmlog.c	2006-09-16 15:52:53 UTC (rev 1028)
+++ trunk/varnish-cache/bin/varnishd/shmlog.c	2006-09-16 15:54:56 UTC (rev 1029)
@@ -27,7 +27,7 @@
 struct varnish_stats *VSL_stats;
 static struct shmloghead *loghead;
 static unsigned char *logstart;
-static pthread_mutex_t vsl_mtx;
+static MTX vsl_mtx;
 
 /*
  * This variant copies a byte-range directly to the log, without
@@ -135,7 +135,7 @@
 	assert(loghead->hdrsize == sizeof *loghead);
 	/* XXX more check sanity of loghead  ? */
 	logstart = (unsigned char *)loghead + loghead->start;
-	AZ(pthread_mutex_init(&vsl_mtx, NULL));
+	MTX_INIT(&vsl_mtx);
 	loghead->starttime = time(NULL);
 	memset(VSL_stats, 0, sizeof *VSL_stats);
 }

Modified: trunk/varnish-cache/bin/varnishd/storage_file.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_file.c	2006-09-16 15:52:53 UTC (rev 1028)
+++ trunk/varnish-cache/bin/varnishd/storage_file.c	2006-09-16 15:54:56 UTC (rev 1029)
@@ -77,7 +77,7 @@
 	struct smfhead		order;
 	struct smfhead		free[NBUCKET];
 	struct smfhead		used;
-	pthread_mutex_t		mtx;
+	MTX			mtx;
 };
 
 /*--------------------------------------------------------------------*/
@@ -492,6 +492,7 @@
 {
 	struct smf *sp, *sp2;
 
+	assert(!(len % sc->pagesize));
 	sp = calloc(sizeof *sp, 1);
 	XXXAN(sp);
 	sp->magic = SMF_MAGIC;
@@ -534,6 +535,7 @@
 	off_t h;
 
 	assert(sz != 0);
+	assert(!(sz % sc->pagesize));
 
 	if (*fail < (uintmax_t)sc->pagesize * MINPAGES)
 		return;
@@ -576,7 +578,7 @@
 	/* XXX */
 	if (sum < MINPAGES * (uintmax_t)getpagesize())
 		exit (2);
-	AZ(pthread_mutex_init(&sc->mtx, NULL));
+	MTX_INIT(&sc->mtx);
 }
 
 /*--------------------------------------------------------------------*/




More information about the varnish-commit mailing list