From 5759ace07f70ed32a40d733bacd35e062c28bd3c 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] Handle pthread_*_init() failures consistently isc_rwlock_init() currently detects pthread_rwlock_init() failures using a REQUIRE() assertion. Use the ERRNO_CHECK() macro for that purpose instead, so that read-write lock initialization failures are handled identically as condition variable (pthread_cond_init()) and mutex (pthread_mutex_init()) initialization failures. --- lib/isc/rwlock.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/isc/rwlock.c b/lib/isc/rwlock.c index 2691a44de4..e9b7968efe 100644 --- a/lib/isc/rwlock.c +++ b/lib/isc/rwlock.c @@ -35,9 +35,13 @@ void isc_rwlock_init(isc_rwlock_t *rwl, unsigned int read_quota, unsigned int write_quota) { + int ret; UNUSED(read_quota); UNUSED(write_quota); - REQUIRE(pthread_rwlock_init(&rwl->rwlock, NULL) == 0); + + ret = pthread_rwlock_init(&rwl->rwlock, NULL); + ERRNO_CHECK(pthread_rwlock_init, ret); + atomic_init(&rwl->downgrade, false); }