Skip to content

Commit

Permalink
default to error checking.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
brlcad committed Jan 6, 2025
1 parent 376b2f3 commit 9e96d9d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/libbu/semaphore.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9e96d9d

Please sign in to comment.