]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
atomic cleanups in tvh_thread, tvhlog (clang)
authorJaroslav Kysela <perex@perex.cz>
Sun, 2 Dec 2018 19:18:36 +0000 (20:18 +0100)
committerJaroslav Kysela <perex@perex.cz>
Sun, 2 Dec 2018 19:18:36 +0000 (20:18 +0100)
src/tvh_thread.c
src/tvhlog.c

index 3050096e4b17d77c1a8596e4a57a0db57f5d6507..d4d2f1972a99aea47e18ad3371c6515fd99eedbd 100644 (file)
@@ -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
index e3d8ca3f673314ec7e5cb3d38a232f8792ffc8b2..156b2110b8a6be8570d23cf86f9cb4a2cecb859a 100644 (file)
@@ -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));