From: Jaroslav Kysela Date: Tue, 8 Mar 2016 14:51:35 +0000 (+0100) Subject: use atomic access for tvhlog_level everywhere X-Git-Tag: v4.2.1~932 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=64030e6c41c263421818b32056dede4da2fdfd02;p=thirdparty%2Ftvheadend.git use atomic access for tvhlog_level everywhere --- diff --git a/src/tvhlog.c b/src/tvhlog.c index 93284fc83..4dc1187e7 100644 --- a/src/tvhlog.c +++ b/src/tvhlog.c @@ -283,7 +283,7 @@ void tvhlogv ( const char *file, int line, options = tvhlog_options; if (severity >= LOG_DEBUG) { ok = 0; - if (severity <= tvhlog_level) { + if (severity <= atomic_add(&tvhlog_level, 0)) { if (tvhlog_trace) { ok = htsmsg_get_u32_or_default(tvhlog_trace, "all", 0); ok = htsmsg_get_u32_or_default(tvhlog_trace, subsys, ok); @@ -573,19 +573,14 @@ static const void * tvhlog_class_trace_get ( void *o ) { static int si; - si = tvhlog_level >= LOG_TRACE; + si = atomic_add(&tvhlog_level, 0) >= LOG_TRACE; return &si; } static int tvhlog_class_trace_set ( void *o, const void *v ) { - pthread_mutex_lock(&tvhlog_mutex); - if (*(int *)v) - tvhlog_level = LOG_TRACE; - else - tvhlog_level = LOG_DEBUG; - pthread_mutex_unlock(&tvhlog_mutex); + atomic_exchange(&tvhlog_level, *(int *)v ? LOG_TRACE : LOG_DEBUG); return 1; }