From badeeff0acf34b36250579970329fe0cd53cbe87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= Date: Wed, 13 Jul 2022 13:19:32 +0200 Subject: [PATCH] Improve reporting for condition variable errors Replace all uses of RUNTIME_CHECK() in lib/isc/include/isc/condition.h with ERRNO_CHECK(), in order to improve error reporting for any condition-variable-related run-time failures (by augmenting error messages with file/line/caller information and the error string corresponding to errno). --- lib/isc/include/isc/condition.h | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/lib/isc/include/isc/condition.h b/lib/isc/include/isc/condition.h index 63d0f98343..445ba4d643 100644 --- a/lib/isc/include/isc/condition.h +++ b/lib/isc/include/isc/condition.h @@ -66,16 +66,29 @@ typedef pthread_cond_t isc_condition_t; ERRNO_CHECK(pthread_cond_init, _ret); \ } -#define isc__condition_wait(cp, mp) \ - RUNTIME_CHECK(pthread_cond_wait((cp), (mp)) == 0) +#define isc__condition_wait(cp, mp) \ + { \ + int _ret = pthread_cond_wait(cp, mp); \ + ERRNO_CHECK(pthread_cond_wait, _ret); \ + } -#define isc__condition_signal(cp) RUNTIME_CHECK(pthread_cond_signal((cp)) == 0) +#define isc__condition_signal(cp) \ + { \ + int _ret = pthread_cond_signal(cp); \ + ERRNO_CHECK(pthread_cond_signal, _ret); \ + } -#define isc__condition_broadcast(cp) \ - RUNTIME_CHECK(pthread_cond_broadcast((cp)) == 0) +#define isc__condition_broadcast(cp) \ + { \ + int _ret = pthread_cond_broadcast(cp); \ + ERRNO_CHECK(pthread_cond_broadcast, _ret); \ + } -#define isc__condition_destroy(cp) \ - RUNTIME_CHECK(pthread_cond_destroy((cp)) == 0) +#define isc__condition_destroy(cp) \ + { \ + int _ret = pthread_cond_destroy(cp); \ + ERRNO_CHECK(pthread_cond_destroy, _ret); \ + } isc_result_t isc__condition_waituntil(pthread_cond_t *, pthread_mutex_t *, isc_time_t *);