Use error checking mutexes

Motivated by #25, which looks like a self-induced deadlock
in fellow_cache_lru_work()
parent da60b18f
......@@ -55,6 +55,15 @@ static char wrongbuf[1024];
WRONG(wrongbuf); \
} while (0)
pthread_mutexattr_t fc_mtxattr_errorcheck;
static void __attribute__((constructor))
init_mutexattr(void)
{
PTOK(pthread_mutexattr_init(&fc_mtxattr_errorcheck));
PTOK(pthread_mutexattr_settype(&fc_mtxattr_errorcheck,
PTHREAD_MUTEX_ERRORCHECK));
}
struct fellow_cache_obj;
// look up objects by fdb
VRBT_HEAD(fellow_cache_fdb_head, fellow_cache_obj);
......@@ -87,7 +96,7 @@ fellow_cache_lru_new(struct fellow_cache *fc)
ALLOC_OBJ(lru, FELLOW_CACHE_LRU_MAGIC);
AN(lru);
lru->fc = fc;
AZ(pthread_mutex_init(&lru->lru_mtx, NULL));
AZ(pthread_mutex_init(&lru->lru_mtx, &fc_mtxattr_errorcheck));
VTAILQ_INIT(&lru->lru_head);
return (lru);
......@@ -749,7 +758,7 @@ fellow_cache_lrus_init(struct fellow_cache_lrus *lrus)
{
INIT_OBJ(lrus, FELLOW_CACHE_LRUS_MAGIC);
AZ(pthread_mutex_init(&lrus->mtx, NULL));
AZ(pthread_mutex_init(&lrus->mtx, &fc_mtxattr_errorcheck));
}
static void
......@@ -1953,7 +1962,7 @@ fellow_cache_obj_new(struct fellow_cache *fc,
fco->fco_mem = fco_mem;
fco->lru = fellow_cache_get_lru(fc, (uintptr_t)fco);
AZ(pthread_mutex_init(&fco->mtx, NULL));
AZ(pthread_mutex_init(&fco->mtx, &fc_mtxattr_errorcheck));
AZ(pthread_cond_init(&fco->cond, NULL));
if (fco_mem.bits) {
......@@ -3463,7 +3472,7 @@ fellow_cache_async_init(struct fellow_cache *fc, fellow_task_run_t taskrun)
entries = fellow_io_ring_size("fellow_cache_io_entries");
DBG("io entries %u", entries);
AZ(pthread_mutex_init(&fc->async_mtx, NULL));
AZ(pthread_mutex_init(&fc->async_mtx, &fc_mtxattr_errorcheck));
AZ(pthread_cond_init(&fc->async_cond, NULL));
fc->async_ioctx = fellow_io_init(fellow_fd(fc->ffd),
entries, fc->membuddy->area, fc->membuddy->map->size,
......@@ -5140,7 +5149,7 @@ fellow_cache_init(struct fellow_fd *ffd, buddy_t *membuddy,
fellow_cache_lrus_init(fc->lrus);
AZ(pthread_mutex_init(&fc->fdb_mtx, NULL));
AZ(pthread_mutex_init(&fc->fdb_mtx, &fc_mtxattr_errorcheck));
VRBT_INIT(&fc->fdb_head);
fellow_cache_async_init(fc, taskrun);
......
......@@ -76,7 +76,7 @@
-esym(749, *_INVAL)
-esym(754, *_reserv*)
// symbol not ref (constructor)
-esym(528, init_fcos_transitions, assert_fcos*)
-esym(528, init_*, assert_fcos*)
-esym(755, BWIT_*)
-esym(755, fc_inj_*, FC_INJ_SZLIM_SET) // not referenced
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment