From: Witold Kręcicki Date: Tue, 28 Jan 2020 10:27:27 +0000 (+0100) Subject: Use isc_rwlock for isc_result tables X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e610325783af82f60b0f7c362da57074f8d3ff35;p=thirdparty%2Fbind9.git Use isc_rwlock for isc_result tables --- diff --git a/lib/isc/result.c b/lib/isc/result.c index ff3ca024138..736be4cc8d2 100644 --- a/lib/isc/result.c +++ b/lib/isc/result.c @@ -15,9 +15,9 @@ #include #include -#include #include #include +#include #include typedef struct resulttable { @@ -182,7 +182,7 @@ static const char *identifier[ISC_R_NRESULTS] = { static isc_once_t once = ISC_ONCE_INIT; static resulttable_list_t description_tables; static resulttable_list_t identifier_tables; -static isc_mutex_t lock; +static isc_rwlock_t lock; static isc_result_t register_table(resulttable_list_t *tables, unsigned int base, @@ -208,11 +208,11 @@ register_table(resulttable_list_t *tables, unsigned int base, table->set = set; ISC_LINK_INIT(table, link); - LOCK(&lock); + RWLOCK(&lock, isc_rwlocktype_write); ISC_LIST_APPEND(*tables, table, link); - UNLOCK(&lock); + RWUNLOCK(&lock, isc_rwlocktype_write); return (ISC_R_SUCCESS); } @@ -221,7 +221,7 @@ static void initialize_action(void) { isc_result_t result; - isc_mutex_init(&lock); + isc_rwlock_init(&lock, 0, 0); ISC_LIST_INIT(description_tables); ISC_LIST_INIT(identifier_tables); @@ -257,7 +257,7 @@ isc_result_tomany_helper(resulttable_list_t *tables, isc_result_t result) { initialize(); - LOCK(&lock); + RWLOCK(&lock, isc_rwlocktype_read); text = NULL; for (table = ISC_LIST_HEAD(*tables); @@ -273,7 +273,7 @@ isc_result_tomany_helper(resulttable_list_t *tables, isc_result_t result) { text = "(result code text not available)"; } - UNLOCK(&lock); + RWUNLOCK(&lock, isc_rwlocktype_read); return (text); }