]> err.no Git - varnish/commitdiff
Assert lock properly held, inspired by unease about #378.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 18 Dec 2008 12:16:45 +0000 (12:16 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 18 Dec 2008 12:16:45 +0000 (12:16 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3474 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/storage_file.c

index 6e110987f86064b45b7be4698e0d3229f9c8e626..13dc4bde7f7236f8637c0e5e35da5f6f1e95ce92 100644 (file)
@@ -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;
 }