From 9e96d9dc9b2220a6af9405167fa57a0cec316b27 Mon Sep 17 00:00:00 2001 From: Christopher Sean Morrison Date: Mon, 6 Jan 2025 02:42:02 -0500 Subject: [PATCH] default to error checking. we don't seem to suffer from deadlocking mutexes nor rely on recursive locking, and error checking may even be the default on some platforms, but better to make it explicit so behavior is (more) defined. --- src/libbu/semaphore.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libbu/semaphore.c b/src/libbu/semaphore.c index 18b9f29fa9..be91d1465c 100644 --- a/src/libbu/semaphore.c +++ b/src/libbu/semaphore.c @@ -164,8 +164,13 @@ bu_semaphore_init(unsigned int nsemaphores) sem_bomb(ret); } for (i=bu_nsemaphores; i < nsemaphores; i++) { + pthread_mutexattr_t attr; memset(&bu_semaphores[i], 0, sizeof(struct bu_semaphores)); - ret = pthread_mutex_init(&bu_semaphores[i].mu, NULL); + + pthread_mutexattr_init(&attr); + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); + ret = pthread_mutex_init(&bu_semaphores[i].mu, &attr); + pthread_mutexattr_destroy(&attr); if (ret) { fprintf(stderr, "bu_semaphore_init(): pthread_mutex_init() failed on [%d] of [%d]\n", i+1, nsemaphores - bu_nsemaphores); sem_bomb(ret);