unsigned magic;
#define ILCK_MAGIC 0x7b86c8a5
pthread_mutex_t mtx;
+ int held;
pthread_t owner;
VTAILQ_ENTRY(ilck) list;
const char *w;
CAST_OBJ_NOTNULL(ilck, lck->priv, ILCK_MAGIC);
if (!(params->diag_bitmap & 0x18)) {
AZ(pthread_mutex_lock(&ilck->mtx));
- AZ(ilck->owner);
+ AZ(ilck->held);
ilck->owner = pthread_self();
+ ilck->held = 1;
return;
}
r = pthread_mutex_trylock(&ilck->mtx);
} else if (params->diag_bitmap & 0x8) {
VSL(SLT_Debug, 0, "MTX_LOCK(%s,%s,%d,%s)", p, f, l, ilck->w);
}
- AZ(ilck->owner);
+ AZ(ilck->held);
ilck->owner = pthread_self();
+ ilck->held = 1;
}
void
struct ilck *ilck;
CAST_OBJ_NOTNULL(ilck, lck->priv, ILCK_MAGIC);
- assert(ilck->owner == pthread_self());
- ilck->owner = NULL;
+ assert(pthread_equal(ilck->owner, pthread_self()));
+ AN(ilck->held);
+ ilck->held = 0;
AZ(pthread_mutex_unlock(&ilck->mtx));
if (params->diag_bitmap & 0x8)
VSL(SLT_Debug, 0, "MTX_UNLOCK(%s,%s,%d,%s)", p, f, l, ilck->w);
VSL(SLT_Debug, 0,
"MTX_TRYLOCK(%s,%s,%d,%s) = %d", p, f, l, ilck->w);
if (r == 0) {
- AZ(ilck->owner);
+ AZ(ilck->held);
+ ilck->held = 1;
ilck->owner = pthread_self();
}
return (r);
CAST_OBJ_NOTNULL(ilck, lck->priv, ILCK_MAGIC);
if (held)
- assert(ilck->owner == pthread_self());
+ assert(ilck->held &&
+ pthread_equal(ilck->owner, pthread_self()));
else
- assert(ilck->owner != pthread_self());
+ assert(!ilck->held ||
+ !pthread_equal(ilck->owner, pthread_self()));
}
void
struct ilck *ilck;
CAST_OBJ_NOTNULL(ilck, lck->priv, ILCK_MAGIC);
- assert(ilck->owner == pthread_self());
- ilck->owner = NULL;
+ AN(ilck->held);
+ assert(pthread_equal(ilck->owner, pthread_self()));
+ ilck->held = 0;
AZ(pthread_cond_wait(cond, &ilck->mtx));
- AZ(ilck->owner);
+ AZ(ilck->held);
ilck->owner = pthread_self();
}