From: Jaroslav Kysela Date: Sun, 2 Dec 2018 19:18:36 +0000 (+0100) Subject: atomic cleanups in tvh_thread, tvhlog (clang) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39b74cbd8624668d03881dbd6e1184c626748788;p=thirdparty%2Ftvheadend.git atomic cleanups in tvh_thread, tvhlog (clang) --- diff --git a/src/tvh_thread.c b/src/tvh_thread.c index 3050096e4..d4d2f1972 100644 --- a/src/tvh_thread.c +++ b/src/tvh_thread.c @@ -416,11 +416,11 @@ static void *tvh_thread_watch_thread(void *aux) int64_t now; tvh_mutex_t *mutex, dmutex; - while (!tvhwatch_done) { + while (!atomic_get(&tvhwatch_done)) { pthread_mutex_lock(&thrwatch_mutex); now = getfastmonoclock(); mutex = TAILQ_LAST(&thrwatch_mutexes, tvh_mutex_queue); - if (mutex && mutex->tstamp + sec2mono(55) < now) { + if (mutex && mutex->tstamp + sec2mono(5) < now) { pthread_mutex_unlock(&thrwatch_mutex); tvh_thread_mutex_deadlock(mutex); } @@ -442,7 +442,7 @@ void tvh_thread_init(int debug_level) tvh_thread_debug = debug_level; tvh_thread_crash_time = getfastmonoclock() + sec2mono(15); if (debug_level > 0) { - tvhwatch_done = 0; + atomic_set(&tvhwatch_done, 0); tvh_thread_create(&thrwatch_tid, NULL, tvh_thread_watch_thread, NULL, "thrwatch"); } #endif @@ -452,7 +452,7 @@ void tvh_thread_done(void) { #if ENABLE_TRACE if (tvh_thread_debug > 0) { - tvhwatch_done = 1; + atomic_set(&tvhwatch_done, 1); pthread_join(thrwatch_tid, NULL); } #endif diff --git a/src/tvhlog.c b/src/tvhlog.c index e3d8ca3f6..156b2110b 100644 --- a/src/tvhlog.c +++ b/src/tvhlog.c @@ -569,7 +569,7 @@ void tvhdbg(int subsys, const char *fmt, ...) void tvhlog_init ( int level, int options, const char *path ) { - tvhlog_level = level; + atomic_set(&tvhlog_level, level); tvhlog_options = options; tvhlog_path = path ? strdup(path) : NULL; memset(tvhlog_trace, 0, sizeof(tvhlog_trace));