MT#55283 use mutex abstraction

Change-Id: I07b9cae328fe14c182aad4d01f0d5bada0b06761
pull/1897/head
Richard Fuchs 1 year ago
parent 0baf79dada
commit a5cd0e4060

@ -87,7 +87,7 @@ int ilog_facility = LOG_DAEMON;
static GHashTable *__log_limiter; 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; 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.prefix = (char *) prefix;
lle.msg = msg; lle.msg = msg;
pthread_mutex_lock(&__log_limiter_lock); LOCK(&__log_limiter_lock);
if (__log_limiter_count > 10000) { if (__log_limiter_count > 10000) {
g_hash_table_remove_all(__log_limiter); 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; when = 0;
} }
pthread_mutex_unlock(&__log_limiter_lock);
if (when) if (when)
return; return;
@ -255,7 +254,6 @@ static void log_limiter_entry_free(void *p) {
} }
void log_init(const char *handle) { 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 = g_hash_table_new_full(log_limiter_entry_hash, log_limiter_entry_equal,
log_limiter_entry_free, NULL); log_limiter_entry_free, NULL);
@ -265,7 +263,6 @@ void log_init(const char *handle) {
void log_free(void) { void log_free(void) {
g_hash_table_destroy(__log_limiter); g_hash_table_destroy(__log_limiter);
pthread_mutex_destroy(&__log_limiter_lock);
} }
int parse_log_facility(const char *name, int *dst) { int parse_log_facility(const char *name, int *dst) {

Loading…
Cancel
Save