r297 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Tue Jul 4 16:18:02 CEST 2006
Author: phk
Date: 2006-07-04 16:18:02 +0200 (Tue, 04 Jul 2006)
New Revision: 297
Modified:
trunk/varnish-cache/bin/varnishd/storage_file.c
Log:
Lock with a mutex
Modified: trunk/varnish-cache/bin/varnishd/storage_file.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_file.c 2006-07-04 13:45:16 UTC (rev 296)
+++ trunk/varnish-cache/bin/varnishd/storage_file.c 2006-07-04 14:18:02 UTC (rev 297)
@@ -53,6 +53,7 @@
struct smfhead order;
struct smfhead free;
struct smfhead used;
+ pthread_mutex_t mtx;
};
/*--------------------------------------------------------------------*/
@@ -462,6 +463,7 @@
/* XXX */
if (sum < MINPAGES * getpagesize())
exit (2);
+ AZ(pthread_mutex_init(&sc->mtx, NULL));
}
/*--------------------------------------------------------------------*/
@@ -474,7 +476,9 @@
size += (sc->pagesize - 1);
size &= ~(sc->pagesize - 1);
+ AZ(pthread_mutex_lock(&sc->mtx));
smf = alloc_smf(sc, size);
+ AZ(pthread_mutex_unlock(&sc->mtx));
assert(smf != NULL);
smf->s.space = size;
smf->s.priv = smf;
@@ -493,14 +497,16 @@
struct smf_sc *sc;
assert(size <= s->space);
- assert(size > 0);
+ assert(size > 0); /* XXX: seen */
smf = (struct smf *)(s->priv);
assert(size <= smf->size);
sc = smf->sc;
size += (sc->pagesize - 1);
size &= ~(sc->pagesize - 1);
if (smf->size > size) {
+ AZ(pthread_mutex_lock(&sc->mtx));
trim_smf(smf, size);
+ AZ(pthread_mutex_unlock(&sc->mtx));
smf->s.space = size;
}
}
@@ -511,9 +517,13 @@
smf_free(struct storage *s)
{
struct smf *smf;
+ struct smf_sc *sc;
smf = (struct smf *)(s->priv);
+ sc = smf->sc;
+ AZ(pthread_mutex_lock(&sc->mtx));
free_smf(smf);
+ AZ(pthread_mutex_unlock(&sc->mtx));
}
/*--------------------------------------------------------------------*/
More information about the varnish-commit
mailing list