Permalink
Browse files

Don't increment the contested counter until we have the lock.

  • Loading branch information...
bsdphk committed Feb 11, 2019
1 parent f7d1c8b commit 2cba061d8d47934af1226b2c87701324d6b84cee
Showing with 3 additions and 4 deletions.
  1. +3 −4 bin/varnishd/cache/cache_lck.c
@@ -114,14 +114,13 @@ Lck__Lock(struct lock *lck, const char *p, int l)
Lck_Witness_Lock(ilck, p, l, "");
if (DO_DEBUG(DBG_LCK)) {
r = pthread_mutex_trylock(&ilck->mtx);
if (r == EBUSY)
ilck->stat->dbg_busy++;
else
AZ(r);
assert(r == 0 || r == EBUSY);
}
if (r)
AZ(pthread_mutex_lock(&ilck->mtx));
AZ(ilck->held);
if (r == EBUSY)
ilck->stat->dbg_busy++;
ilck->stat->locks++;
ilck->owner = pthread_self();
ilck->held = 1;

0 comments on commit 2cba061

Please sign in to comment.