Mailing List Archive

r913 - in trunk/varnish-cache: bin/varnishd include
Author: phk
Date: 2006-08-24 09:17:35 +0200 (Thu, 24 Aug 2006)
New Revision: 913

Modified:
trunk/varnish-cache/bin/varnishd/cache_backend.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
trunk/varnish-cache/include/libvarnish.h
Log:
Introduce LOCK() and UNLOCK() macros which does the right thing
with pthread_mutex_{lock,unlock}()



Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend.c 2006-08-24 07:10:35 UTC (rev 912)
+++ trunk/varnish-cache/bin/varnishd/cache_backend.c 2006-08-24 07:17:35 UTC (rev 913)
@@ -187,7 +187,7 @@
* (if any) while we have the lock anyway.
*/
vc2 = NULL;
- AZ(pthread_mutex_lock(&vbemtx));
+ LOCK(&vbemtx);
vc = TAILQ_FIRST(&bp->connlist);
if (vc != NULL) {
assert(vc->fd >= 0);
@@ -199,7 +199,7 @@
TAILQ_REMOVE(&vbe_head, vc2, list);
}
}
- AZ(pthread_mutex_unlock(&vbemtx));
+ UNLOCK(&vbemtx);
if (vc == NULL)
break;

@@ -226,7 +226,7 @@
if (vc->fd < 0) {
assert(vc->backend == NULL);
vc->fd = vbe_connect(bp);
- AZ(pthread_mutex_lock(&vbemtx));
+ LOCK(&vbemtx);
if (vc->fd < 0) {
vc->backend = NULL;
TAILQ_INSERT_HEAD(&vbe_head, vc, list);
@@ -235,7 +235,7 @@
} else {
vc->backend = bp;
}
- AZ(pthread_mutex_unlock(&vbemtx));
+ UNLOCK(&vbemtx);
} else {
assert(vc->fd >= 0);
assert(vc->backend == bp);
@@ -263,10 +263,10 @@
AZ(close(vc->fd));
vc->fd = -1;
vc->backend = NULL;
- AZ(pthread_mutex_lock(&vbemtx));
+ LOCK(&vbemtx);
TAILQ_INSERT_HEAD(&vbe_head, vc, list);
VSL_stats->backend_unused++;
- AZ(pthread_mutex_unlock(&vbemtx));
+ UNLOCK(&vbemtx);
}

/* Recycle a connection ----------------------------------------------*/
@@ -280,9 +280,9 @@
assert(vc->backend != NULL);
VSL_stats->backend_recycle++;
VSL(SLT_BackendReuse, vc->fd, "%s", vc->backend->vcl_name);
- AZ(pthread_mutex_lock(&vbemtx));
+ LOCK(&vbemtx);
TAILQ_INSERT_HEAD(&vc->backend->connlist, vc, list);
- AZ(pthread_mutex_unlock(&vbemtx));
+ UNLOCK(&vbemtx);
}

/*--------------------------------------------------------------------*/

Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_expire.c 2006-08-24 07:10:35 UTC (rev 912)
+++ trunk/varnish-cache/bin/varnishd/cache_expire.c 2006-08-24 07:17:35 UTC (rev 913)
@@ -32,19 +32,19 @@
{

assert(o->heap_idx == 0);
- AZ(pthread_mutex_lock(&exp_mtx));
+ LOCK(&exp_mtx);
binheap_insert(exp_heap, o);
- AZ(pthread_mutex_unlock(&exp_mtx));
+ UNLOCK(&exp_mtx);
}

void
EXP_TTLchange(struct object *o)
{
assert(o->heap_idx != 0);
- AZ(pthread_mutex_lock(&exp_mtx));
+ LOCK(&exp_mtx);
binheap_delete(exp_heap, o->heap_idx);
binheap_insert(exp_heap, o);
- AZ(pthread_mutex_unlock(&exp_mtx));
+ UNLOCK(&exp_mtx);
}

/*--------------------------------------------------------------------
@@ -61,7 +61,7 @@

while (1) {
t = time(NULL);
- AZ(pthread_mutex_lock(&exp_mtx));
+ LOCK(&exp_mtx);
TAILQ_FOREACH(o, &exp_deathrow, deathrow) {
CHECK_OBJ(o, OBJECT_MAGIC);
if (o->ttl >= t) {
@@ -77,14 +77,14 @@
break;
}
if (o == NULL) {
- AZ(pthread_mutex_unlock(&exp_mtx));
+ UNLOCK(&exp_mtx);
AZ(sleep(1));
continue;
}
TAILQ_REMOVE(&exp_deathrow, o, deathrow);
VSL_stats->n_deathrow--;
VSL_stats->n_expired++;
- AZ(pthread_mutex_unlock(&exp_mtx));
+ UNLOCK(&exp_mtx);
VSL(SLT_ExpKill, 0, "%u %d", o->xid, (int)(o->ttl - t));
HSH_Deref(o);
}
@@ -113,12 +113,12 @@
assert(sp != NULL);
while (1) {
t = time(NULL);
- AZ(pthread_mutex_lock(&exp_mtx));
+ LOCK(&exp_mtx);
o = binheap_root(exp_heap);
if (o != NULL)
CHECK_OBJ(o, OBJECT_MAGIC);
if (o == NULL || o->ttl > t + expearly) {
- AZ(pthread_mutex_unlock(&exp_mtx));
+ UNLOCK(&exp_mtx);
AZ(sleep(1));
continue;
}
@@ -129,7 +129,7 @@
if (o2 != NULL)
assert(o2->ttl >= o->ttl);

- AZ(pthread_mutex_unlock(&exp_mtx));
+ UNLOCK(&exp_mtx);
VSL(SLT_ExpPick, 0, "%u", o->xid);

sp->vcl = VCL_Get();
@@ -138,10 +138,10 @@
VCL_Rel(sp->vcl);

if (sp->handling == VCL_RET_DISCARD) {
- AZ(pthread_mutex_lock(&exp_mtx));
+ LOCK(&exp_mtx);
TAILQ_INSERT_TAIL(&exp_deathrow, o, deathrow);
VSL_stats->n_deathrow++;
- AZ(pthread_mutex_unlock(&exp_mtx));
+ UNLOCK(&exp_mtx);
continue;
}
assert(sp->handling == VCL_RET_DISCARD);

Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_hash.c 2006-08-24 07:10:35 UTC (rev 912)
+++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2006-08-24 07:17:35 UTC (rev 913)
@@ -85,20 +85,20 @@
o = sp->obj;
oh = o->objhead;
CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
- AZ(pthread_mutex_lock(&oh->mtx));
+ LOCK(&oh->mtx);
goto were_back;
}
oh = hash->lookup(url, host, w->nobjhead);
CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
if (oh == w->nobjhead)
w->nobjhead = NULL;
- AZ(pthread_mutex_lock(&oh->mtx));
+ LOCK(&oh->mtx);
TAILQ_FOREACH(o, &oh->objects, list) {
o->refcnt++;
if (o->busy) {
TAILQ_INSERT_TAIL(&o->waitinglist, sp, list);
sp->obj = o;
- AZ(pthread_mutex_unlock(&oh->mtx));
+ UNLOCK(&oh->mtx);
return (NULL);
}
were_back:
@@ -118,7 +118,7 @@
o->refcnt--;
}
if (o != NULL) {
- AZ(pthread_mutex_unlock(&oh->mtx));
+ UNLOCK(&oh->mtx);
(void)hash->deref(oh);
return (o);
}
@@ -129,7 +129,7 @@
o->objhead = oh;
TAILQ_INSERT_TAIL(&oh->objects, o, list);
/* NB: do not deref objhead the new object inherits our reference */
- AZ(pthread_mutex_unlock(&oh->mtx));
+ UNLOCK(&oh->mtx);
BAN_NewObj(o);
return (o);
}
@@ -144,9 +144,9 @@
assert(o->refcnt > 0);
if (o->cacheable)
EXP_Insert(o);
- AZ(pthread_mutex_lock(&o->objhead->mtx));
+ LOCK(&o->objhead->mtx);
o->busy = 0;
- AZ(pthread_mutex_unlock(&o->objhead->mtx));
+ UNLOCK(&o->objhead->mtx);
while (1) {
sp = TAILQ_FIRST(&o->waitinglist);
if (sp == NULL)
@@ -164,10 +164,10 @@
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
oh = o->objhead;
CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
- AZ(pthread_mutex_lock(&oh->mtx));
+ LOCK(&oh->mtx);
assert(o->refcnt > 0);
o->refcnt++;
- AZ(pthread_mutex_unlock(&oh->mtx));
+ UNLOCK(&oh->mtx);
}

void
@@ -182,12 +182,12 @@
CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);

/* drop ref on object */
- AZ(pthread_mutex_lock(&oh->mtx));
+ LOCK(&oh->mtx);
assert(o->refcnt > 0);
r = --o->refcnt;
if (!r)
TAILQ_REMOVE(&oh->objects, o, list);
- AZ(pthread_mutex_unlock(&oh->mtx));
+ UNLOCK(&oh->mtx);

/* If still referenced, done */
if (r != 0)

Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c 2006-08-24 07:10:35 UTC (rev 912)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2006-08-24 07:17:35 UTC (rev 913)
@@ -132,7 +132,7 @@
VSL_stats->n_wrk_busy++;
TAILQ_REMOVE(&wrk_reqhead, wrq, list);
VSL_stats->n_wrk_queue--;
- AZ(pthread_mutex_unlock(&wrk_mtx));
+ UNLOCK(&wrk_mtx);
CHECK_OBJ_NOTNULL(wrq->sess, SESS_MAGIC);
wrq->sess->wrk = w;
w->wrq = wrq;
@@ -150,7 +150,7 @@
if (w->nobjhead != NULL)
CHECK_OBJ(w->nobjhead, OBJHEAD_MAGIC);
w->wrq = NULL;
- AZ(pthread_mutex_lock(&wrk_mtx));
+ LOCK(&wrk_mtx);
VSL_stats->n_wrk_busy--;
}

@@ -167,7 +167,7 @@

AZ(pthread_cond_init(&w->cv, NULL));

- AZ(pthread_mutex_lock(&wrk_mtx));
+ LOCK(&wrk_mtx);
w->nbr = VSL_stats->n_wrk;
VSL_stats->n_wrk_create++;
VSL(SLT_WorkThread, 0, "%u born", w->nbr);
@@ -195,7 +195,7 @@
if (pthread_cond_timedwait(&w->cv, &wrk_mtx, &ts)) {
VSL_stats->n_wrk--;
TAILQ_REMOVE(&wrk_idle, w, list);
- AZ(pthread_mutex_unlock(&wrk_mtx));
+ UNLOCK(&wrk_mtx);
VSL(SLT_WorkThread, 0, "%u suicide", w->nbr);
AZ(pthread_cond_destroy(&w->cv));
return (NULL);
@@ -219,7 +219,7 @@

sp->workreq.sess = sp;

- AZ(pthread_mutex_lock(&wrk_mtx));
+ LOCK(&wrk_mtx);
TAILQ_INSERT_TAIL(&wrk_reqhead, &sp->workreq, list);
VSL_stats->n_wrk_queue++;

@@ -229,7 +229,7 @@
AZ(pthread_cond_signal(&w->cv));
TAILQ_REMOVE(&wrk_idle, w, list);
TAILQ_INSERT_TAIL(&wrk_busy, w, list);
- AZ(pthread_mutex_unlock(&wrk_mtx));
+ UNLOCK(&wrk_mtx);
return;
}

@@ -238,13 +238,13 @@
/* Can we create more threads ? */
if (VSL_stats->n_wrk >= params->wthread_max) {
VSL_stats->n_wrk_max++;
- AZ(pthread_mutex_unlock(&wrk_mtx));
+ UNLOCK(&wrk_mtx);
return;
}

/* Try to create a thread */
VSL_stats->n_wrk++;
- AZ(pthread_mutex_unlock(&wrk_mtx));
+ UNLOCK(&wrk_mtx);

if (!pthread_create(&tp, NULL, wrk_thread, NULL)) {
AZ(pthread_detach(tp));
@@ -255,10 +255,10 @@
errno, strerror(errno));

/* Register overflow */
- AZ(pthread_mutex_lock(&wrk_mtx));
+ LOCK(&wrk_mtx);
VSL_stats->n_wrk--;
VSL_stats->n_wrk_failed++;
- AZ(pthread_mutex_unlock(&wrk_mtx));
+ UNLOCK(&wrk_mtx);
}


@@ -293,7 +293,7 @@
(void)av;
(void)priv;
struct worker *w;
- AZ(pthread_mutex_lock(&wrk_mtx));
+ LOCK(&wrk_mtx);
t = time(NULL);
TAILQ_FOREACH(w, &wrk_busy, list) {
cli_out(cli, "\n");
@@ -313,5 +313,5 @@
TAILQ_FOREACH(w, &wrk_idle, list)
u++;
cli_out(cli, "%u idle workers\n", u);
- AZ(pthread_mutex_unlock(&wrk_mtx));
+ UNLOCK(&wrk_mtx);
}

Modified: trunk/varnish-cache/bin/varnishd/cache_session.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_session.c 2006-08-24 07:10:35 UTC (rev 912)
+++ trunk/varnish-cache/bin/varnishd/cache_session.c 2006-08-24 07:17:35 UTC (rev 913)
@@ -79,7 +79,7 @@
ch = &srcaddr_hash[v];
now = time(NULL);

- AZ(pthread_mutex_lock(&ses_mtx));
+ LOCK(&ses_mtx);
c3 = NULL;
TAILQ_FOREACH_SAFE(c, ch, list, c2) {
if (c->hash == u && !strcmp(c->addr, sp->addr)) {
@@ -95,7 +95,7 @@
VSL_stats->n_srcaddr--;
free(c3);
}
- AZ(pthread_mutex_unlock(&ses_mtx));
+ UNLOCK(&ses_mtx);
return;
}
if (c->nref > 0 || c->ttl > now)
@@ -128,7 +128,7 @@
TAILQ_INSERT_TAIL(ch, c3, list);
sp->srcaddr = c3;
}
- AZ(pthread_mutex_unlock(&ses_mtx));
+ UNLOCK(&ses_mtx);
}

static void
@@ -152,7 +152,7 @@

ses_sum_acct(&sp->acct, a);

- AZ(pthread_mutex_lock(&ses_mtx));
+ LOCK(&ses_mtx);
ses_sum_acct(b, a);
VSL(SLT_StatAddr, 0, "%s 0 %d %ju %ju %ju %ju %ju %ju %ju",
sp->srcaddr->addr, time(NULL) - b->first,
@@ -165,7 +165,7 @@
VSL_stats->s_fetch += a->fetch;
VSL_stats->s_hdrbytes += a->hdrbytes;
VSL_stats->s_bodybytes += a->bodybytes;
- AZ(pthread_mutex_unlock(&ses_mtx));
+ UNLOCK(&ses_mtx);
memset(a, 0, sizeof *a);
}

@@ -178,13 +178,13 @@
return;
}
assert(sp->srcaddr != NULL);
- AZ(pthread_mutex_lock(&ses_mtx));
+ LOCK(&ses_mtx);
assert(sp->srcaddr->nref > 0);
sp->srcaddr->nref--;
if (sp->srcaddr->nref == 0)
VSL_stats->n_srcaddr_act--;
sp->srcaddr = NULL;
- AZ(pthread_mutex_unlock(&ses_mtx));
+ UNLOCK(&ses_mtx);
}

/*--------------------------------------------------------------------*/
@@ -207,9 +207,9 @@
* If that queue is empty, flip queues holding the lock
* and try the new unlocked queue.
*/
- AZ(pthread_mutex_lock(&ses_mem_mtx));
+ LOCK(&ses_mem_mtx);
ses_qp = 1 - ses_qp;
- AZ(pthread_mutex_unlock(&ses_mem_mtx));
+ UNLOCK(&ses_mem_mtx);
sm = TAILQ_FIRST(&ses_free_mem[ses_qp]);
}
if (sm != NULL) {
@@ -271,9 +271,9 @@
VSL_stats->n_sess_mem--;
free(sm);
} else {
- AZ(pthread_mutex_lock(&ses_mem_mtx));
+ LOCK(&ses_mem_mtx);
TAILQ_INSERT_HEAD(&ses_free_mem[1 - ses_qp], sm, list);
- AZ(pthread_mutex_unlock(&ses_mem_mtx));
+ UNLOCK(&ses_mem_mtx);
}
}


Modified: trunk/varnish-cache/bin/varnishd/cache_vcl.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vcl.c 2006-08-24 07:10:35 UTC (rev 912)
+++ trunk/varnish-cache/bin/varnishd/cache_vcl.c 2006-08-24 07:17:35 UTC (rev 913)
@@ -46,12 +46,12 @@
{
struct VCL_conf *vc;

- AZ(pthread_mutex_lock(&vcl_mtx));
+ LOCK(&vcl_mtx);
assert(vcl_active != NULL);
vc = vcl_active->conf;
assert(vc != NULL);
vc->busy++;
- AZ(pthread_mutex_unlock(&vcl_mtx));
+ UNLOCK(&vcl_mtx);
return (vc);
}

@@ -60,7 +60,7 @@
{
struct vcls *vcl;

- AZ(pthread_mutex_lock(&vcl_mtx));
+ LOCK(&vcl_mtx);
assert(vc->busy > 0);
vc->busy--;
vcl = vc->priv; /* XXX miniobj */
@@ -72,7 +72,7 @@
} else {
vcl = NULL;
}
- AZ(pthread_mutex_unlock(&vcl_mtx));
+ UNLOCK(&vcl_mtx);
if (vcl != NULL) {
/* XXX: dispose of vcl */
}
@@ -142,10 +142,10 @@
vcl->name = strdup(name);
assert(vcl->name != NULL);
TAILQ_INSERT_TAIL(&vcl_head, vcl, list);
- AZ(pthread_mutex_lock(&vcl_mtx));
+ LOCK(&vcl_mtx);
if (vcl_active == NULL)
vcl_active = vcl;
- AZ(pthread_mutex_unlock(&vcl_mtx));
+ UNLOCK(&vcl_mtx);
if (cli == NULL)
fprintf(stderr, "Loaded \"%s\" as \"%s\"\n", fn , name);
else
@@ -200,9 +200,9 @@
cli_out(cli, "VCL %s already discarded", av[2]);
return;
}
- AZ(pthread_mutex_lock(&vcl_mtx));
+ LOCK(&vcl_mtx);
if (vcl == vcl_active) {
- AZ(pthread_mutex_unlock(&vcl_mtx));
+ UNLOCK(&vcl_mtx);
cli_result(cli, CLIS_PARAM);
cli_out(cli, "VCL %s is the active VCL", av[2]);
return;
@@ -212,7 +212,7 @@
TAILQ_REMOVE(&vcl_head, vcl, list);
else
vcl = NULL;
- AZ(pthread_mutex_unlock(&vcl_mtx));
+ UNLOCK(&vcl_mtx);
if (vcl != NULL) {
/* XXX dispose of vcl */
}
@@ -236,9 +236,9 @@
cli_result(cli, CLIS_PARAM);
return;
}
- AZ(pthread_mutex_lock(&vcl_mtx));
+ LOCK(&vcl_mtx);
vcl_active = vcl;
- AZ(pthread_mutex_unlock(&vcl_mtx));
+ UNLOCK(&vcl_mtx);
}

/*--------------------------------------------------------------------*/

Modified: trunk/varnish-cache/bin/varnishd/hash_classic.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/hash_classic.c 2006-08-24 07:10:35 UTC (rev 912)
+++ trunk/varnish-cache/bin/varnishd/hash_classic.c 2006-08-24 07:17:35 UTC (rev 913)
@@ -180,7 +180,7 @@
he2 = NULL;

for (r = 0; r < 2; r++ ) {
- AZ(pthread_mutex_lock(&hp->mtx));
+ LOCK(&hp->mtx);
TAILQ_FOREACH(he, &hp->head, list) {
CHECK_OBJ_NOTNULL(he, HCL_ENTRY_MAGIC);
if (kl < he->klen)
@@ -197,13 +197,13 @@
continue;
he->refcnt++;
noh = he->oh;
- AZ(pthread_mutex_unlock(&hp->mtx));
+ UNLOCK(&hp->mtx);
if (he2 != NULL)
free(he2);
return (noh);
}
if (noh == NULL) {
- AZ(pthread_mutex_unlock(&hp->mtx));
+ UNLOCK(&hp->mtx);
return (NULL);
}
if (he2 != NULL) {
@@ -213,10 +213,10 @@
TAILQ_INSERT_TAIL(&hp->head, he2, list);
he2->refcnt++;
noh = he2->oh;
- AZ(pthread_mutex_unlock(&hp->mtx));
+ UNLOCK(&hp->mtx);
return (noh);
}
- AZ(pthread_mutex_unlock(&hp->mtx));
+ UNLOCK(&hp->mtx);

i = sizeof *he2 + kl;
he2 = calloc(i, 1);
@@ -254,12 +254,12 @@
assert(he->refcnt > 0);
assert(he->hash < hcl_nhash);
assert(hp == &hcl_head[he->hash]);
- AZ(pthread_mutex_lock(&hp->mtx));
+ LOCK(&hp->mtx);
if (--he->refcnt == 0)
TAILQ_REMOVE(&hp->head, he, list);
else
he = NULL;
- AZ(pthread_mutex_unlock(&hp->mtx));
+ UNLOCK(&hp->mtx);
if (he == NULL)
return (1);
free(he);

Modified: trunk/varnish-cache/bin/varnishd/hash_simple_list.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/hash_simple_list.c 2006-08-24 07:10:35 UTC (rev 912)
+++ trunk/varnish-cache/bin/varnishd/hash_simple_list.c 2006-08-24 07:17:35 UTC (rev 913)
@@ -48,7 +48,7 @@
struct hsl_entry *he, *he2;
int i;

- AZ(pthread_mutex_lock(&hsl_mutex));
+ LOCK(&hsl_mutex);
TAILQ_FOREACH(he, &hsl_head, list) {
i = strcmp(key1, he->key1);
if (i < 0)
@@ -63,11 +63,11 @@
he->refcnt++;
nobj = he->obj;
nobj->hashpriv = he;
- AZ(pthread_mutex_unlock(&hsl_mutex));
+ UNLOCK(&hsl_mutex);
return (nobj);
}
if (nobj == NULL) {
- AZ(pthread_mutex_unlock(&hsl_mutex));
+ UNLOCK(&hsl_mutex);
return (NULL);
}
he2 = calloc(sizeof *he2, 1);
@@ -83,7 +83,7 @@
TAILQ_INSERT_BEFORE(he, he2, list);
else
TAILQ_INSERT_TAIL(&hsl_head, he2, list);
- AZ(pthread_mutex_unlock(&hsl_mutex));
+ UNLOCK(&hsl_mutex);
return (nobj);
}

@@ -99,7 +99,7 @@

assert(obj->hashpriv != NULL);
he = obj->hashpriv;
- AZ(pthread_mutex_lock(&hsl_mutex));
+ LOCK(&hsl_mutex);
if (--he->refcnt == 0) {
free(he->key1);
free(he->key2);
@@ -108,7 +108,7 @@
ret = 0;
} else
ret = 1;
- AZ(pthread_mutex_unlock(&hsl_mutex));
+ UNLOCK(&hsl_mutex);
return (ret);
}


Modified: trunk/varnish-cache/bin/varnishd/shmlog.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/shmlog.c 2006-08-24 07:10:35 UTC (rev 912)
+++ trunk/varnish-cache/bin/varnishd/shmlog.c 2006-08-24 07:17:35 UTC (rev 913)
@@ -62,7 +62,7 @@
}

/* Only hold the lock while we find our space */
- AZ(pthread_mutex_lock(&vsl_mtx));
+ LOCK(&vsl_mtx);
assert(loghead->ptr < loghead->size);

/* Wrap if necessary */
@@ -72,7 +72,7 @@
loghead->ptr += 5 + l;
p[5 + l] = SLT_ENDMARKER;
assert(loghead->ptr < loghead->size);
- AZ(pthread_mutex_unlock(&vsl_mtx));
+ UNLOCK(&vsl_mtx);

p[1] = l & 0xff;
p[2] = (id >> 8) & 0xff;
@@ -99,7 +99,7 @@
return;
}

- AZ(pthread_mutex_lock(&vsl_mtx));
+ LOCK(&vsl_mtx);
assert(loghead->ptr < loghead->size);

/* Wrap if we cannot fit a full size record */
@@ -123,7 +123,7 @@
loghead->ptr += 5 + n;
assert(loghead->ptr < loghead->size);

- AZ(pthread_mutex_unlock(&vsl_mtx));
+ UNLOCK(&vsl_mtx);

va_end(ap);
}

Modified: trunk/varnish-cache/bin/varnishd/storage_file.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_file.c 2006-08-24 07:10:35 UTC (rev 912)
+++ trunk/varnish-cache/bin/varnishd/storage_file.c 2006-08-24 07:17:35 UTC (rev 913)
@@ -511,10 +511,10 @@

size += (sc->pagesize - 1);
size &= ~(sc->pagesize - 1);
- AZ(pthread_mutex_lock(&sc->mtx));
+ LOCK(&sc->mtx);
smf = alloc_smf(sc, size);
CHECK_OBJ_NOTNULL(smf, SMF_MAGIC);
- AZ(pthread_mutex_unlock(&sc->mtx));
+ UNLOCK(&sc->mtx);
assert(smf != NULL);
assert(smf->size == size);
smf->s.space = size;
@@ -549,10 +549,10 @@
size += (sc->pagesize - 1);
size &= ~(sc->pagesize - 1);
if (smf->size > size) {
- AZ(pthread_mutex_lock(&sc->mtx));
+ LOCK(&sc->mtx);
trim_smf(smf, size);
assert(smf->size == size);
- AZ(pthread_mutex_unlock(&sc->mtx));
+ UNLOCK(&sc->mtx);
smf->s.space = size;
}
}
@@ -568,9 +568,9 @@
CHECK_OBJ_NOTNULL(s, STORAGE_MAGIC);
CAST_OBJ_NOTNULL(smf, s->priv, SMF_MAGIC);
sc = smf->sc;
- AZ(pthread_mutex_lock(&sc->mtx));
+ LOCK(&sc->mtx);
free_smf(smf);
- AZ(pthread_mutex_unlock(&sc->mtx));
+ UNLOCK(&sc->mtx);
}

/*--------------------------------------------------------------------*/

Modified: trunk/varnish-cache/include/libvarnish.h
===================================================================
--- trunk/varnish-cache/include/libvarnish.h 2006-08-24 07:10:35 UTC (rev 912)
+++ trunk/varnish-cache/include/libvarnish.h 2006-08-24 07:17:35 UTC (rev 913)
@@ -51,3 +51,6 @@
#define AN(foo) do { assert((foo) != NULL); } while (0)
#define XXXAZ(foo) do { xxxassert((foo) == 0); } while (0)
#define XXXAN(foo) do { xxxassert((foo) != NULL); } while (0)
+
+#define LOCK(foo) AZ(pthread_mutex_lock(foo))
+#define UNLOCK(foo) AZ(pthread_mutex_unlock(foo))