pthread: use recursive mutexes to allow callbacks to enqueue new c-ares queries. Regression from 1.31.0.

v1.28
Brad House 8 months ago
parent 743525a022
commit 9795e8c7fd
  1. 16
      src/lib/ares__threads.c

@ -219,18 +219,30 @@ struct ares__thread_mutex {
ares__thread_mutex_t *ares__thread_mutex_create(void)
{
pthread_mutexattr_t attr;
ares__thread_mutex_t *mut = ares_malloc_zero(sizeof(*mut));
if (mut == NULL) {
return NULL;
}
if (pthread_mutex_init(&mut->mutex, NULL) != 0) {
goto fail;
if (pthread_mutexattr_init(&attr) != 0) {
ares_free(mut); /* LCOV_EXCL_LINE: UntestablePath */
return NULL; /* LCOV_EXCL_LINE: UntestablePath */
}
if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) != 0) {
goto fail; /* LCOV_EXCL_LINE: UntestablePath */
}
if (pthread_mutex_init(&mut->mutex, &attr) != 0) {
goto fail; /* LCOV_EXCL_LINE: UntestablePath */
}
pthread_mutexattr_destroy(&attr);
return mut;
fail:
pthread_mutexattr_destroy(&attr);
ares_free(mut);
return NULL;
}

Loading…
Cancel
Save