r3474 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Thu Dec 18 13:16:45 CET 2008


Author: phk
Date: 2008-12-18 13:16:45 +0100 (Thu, 18 Dec 2008)
New Revision: 3474

Modified:
   trunk/varnish-cache/bin/varnishd/storage_file.c
Log:
Assert lock properly held, inspired by unease about #378.



Modified: trunk/varnish-cache/bin/varnishd/storage_file.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_file.c	2008-12-18 12:00:43 UTC (rev 3473)
+++ trunk/varnish-cache/bin/varnishd/storage_file.c	2008-12-18 12:16:45 UTC (rev 3474)
@@ -343,6 +343,7 @@
 
 	assert(sp->alloc == 0);
 	assert(sp->flist == NULL);
+	Lck_AssertHeld(&sc->mtx);
 	b = sp->size / sc->pagesize;
 	if (b >= NBUCKET) {
 		b = NBUCKET - 1;
@@ -372,6 +373,7 @@
 
 	assert(sp->alloc == 0);
 	assert(sp->flist != NULL);
+	Lck_AssertHeld(&sc->mtx);
 	b = sp->size / sc->pagesize;
 	if (b >= NBUCKET) {
 		b = NBUCKET - 1;
@@ -602,14 +604,16 @@
 
 	sc = st->priv;
 
+	Lck_New(&sc->mtx);
+	Lck_Lock(&sc->mtx);
 	smf_open_chunk(sc, sc->filesize, 0, &fail, &sum);
+	Lck_Unlock(&sc->mtx);
 	printf("managed to mmap %ju bytes of %ju\n",
 	    (uintmax_t)sum, sc->filesize);
 
 	/* XXX */
 	if (sum < MINPAGES * (off_t)getpagesize())
 		exit (2);
-	Lck_New(&sc->mtx);
 
 	VSL_stats->sm_bfree += sc->filesize;
 }



More information about the varnish-commit mailing list