From 7073caf4cd6fcce82590b41674c77bfe30d1835d Mon Sep 17 00:00:00 2001 From: phk Date: Thu, 18 Dec 2008 12:16:45 +0000 Subject: [PATCH] Assert lock properly held, inspired by unease about #378. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3474 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/storage_file.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/varnish-cache/bin/varnishd/storage_file.c b/varnish-cache/bin/varnishd/storage_file.c index 6e110987..13dc4bde 100644 --- a/varnish-cache/bin/varnishd/storage_file.c +++ b/varnish-cache/bin/varnishd/storage_file.c @@ -343,6 +343,7 @@ insfree(struct smf_sc *sc, struct smf *sp) 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 @@ remfree(const struct smf_sc *sc, struct smf *sp) 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 @@ smf_open(const struct stevedore *st) 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; } -- 2.39.5