Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
use atomic access for tvhlog_level everywhere
  • Loading branch information
perexg committed Mar 8, 2016
1 parent 62d9242 commit 64030e6
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/tvhlog.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 64030e6

Please sign in to comment.