From a5cd0e4060b1f3dcdb6372430a1be52654498363 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 14 Jan 2025 11:44:33 -0400 Subject: [PATCH] MT#55283 use mutex abstraction Change-Id: I07b9cae328fe14c182aad4d01f0d5bada0b06761 --- lib/loglib.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/loglib.c b/lib/loglib.c index 2fa77ddf5..1b181bdd1 100644 --- a/lib/loglib.c +++ b/lib/loglib.c @@ -87,7 +87,7 @@ int ilog_facility = LOG_DAEMON; static GHashTable *__log_limiter; -static pthread_mutex_t __log_limiter_lock; +static mutex_t __log_limiter_lock = MUTEX_STATIC_INIT; static unsigned int __log_limiter_count; @@ -165,7 +165,7 @@ void __vpilog(int prio, const char *prefix, const char *fmt, va_list ap) { lle.prefix = (char *) prefix; lle.msg = msg; - pthread_mutex_lock(&__log_limiter_lock); + LOCK(&__log_limiter_lock); if (__log_limiter_count > 10000) { g_hash_table_remove_all(__log_limiter); @@ -184,7 +184,6 @@ void __vpilog(int prio, const char *prefix, const char *fmt, va_list ap) { when = 0; } - pthread_mutex_unlock(&__log_limiter_lock); if (when) return; @@ -255,7 +254,6 @@ static void log_limiter_entry_free(void *p) { } void log_init(const char *handle) { - pthread_mutex_init(&__log_limiter_lock, NULL); __log_limiter = g_hash_table_new_full(log_limiter_entry_hash, log_limiter_entry_equal, log_limiter_entry_free, NULL); @@ -265,7 +263,6 @@ void log_init(const char *handle) { void log_free(void) { g_hash_table_destroy(__log_limiter); - pthread_mutex_destroy(&__log_limiter_lock); } int parse_log_facility(const char *name, int *dst) {