]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
add mtimer tick thread to update mono timer 10x in one second
authorJaroslav Kysela <perex@perex.cz>
Sat, 5 Mar 2016 16:08:51 +0000 (17:08 +0100)
committerJaroslav Kysela <perex@perex.cz>
Sat, 5 Mar 2016 16:08:51 +0000 (17:08 +0100)
src/main.c
src/tcp.c
src/webui/webui.c

index 4e84701f7262ac6aaa6490dab4484a36115be5f7..06890e910664626276e0f034cf5523f4e9ac180c 100644 (file)
@@ -177,6 +177,7 @@ static LIST_HEAD(, mtimer) mtimers;
 static tvh_cond_t mtimer_cond;
 static int64_t mtimer_periodic;
 static pthread_t mtimer_tid;
+static pthread_t mtimer_tick_tid;
 static LIST_HEAD(, gtimer) gtimers;
 static pthread_cond_t gtimer_cond;
 static TAILQ_HEAD(, tasklet) tasklets;
@@ -527,6 +528,20 @@ mdispatch_clock_update(void)
   return mdispatch_clock = mono;
 }
 
+/**
+ *
+ */
+static void *
+mtimer_tick_thread(void *aux)
+{
+  while (tvheadend_running) {
+    /* update clocks each 10x in one second */
+    mdispatch_clock = getmonoclock();
+    tvh_safe_usleep(100000);
+  }
+  return NULL;
+}
+
 /**
  *
  */
@@ -1098,6 +1113,7 @@ main(int argc, char **argv)
 
   epg_in_load = 1;
 
+  tvhthread_create(&mtimer_tick_tid, NULL, mtimer_tick_thread, NULL, "mtick");
   tvhthread_create(&tasklet_tid, NULL, tasklet_thread, NULL, "tasklet");
 
   dbus_server_init(opt_dbus, opt_dbus_session);
@@ -1254,6 +1270,9 @@ main(int argc, char **argv)
   tvhtrace("main", "tasklet thread end");
   tasklet_flush();
   tvhtrace("main", "tasklet leave");
+  tvhtrace("main", "mtimer tick thread join enter");
+  pthread_join(tasklet_tid, NULL);
+  tvhtrace("main", "mtimer tick thread join leave");
 
   tvhftrace("main", dvb_done);
   tvhftrace("main", lang_str_done);
index a0eb978260a37751a3c9f1e832a243fd9dff89dc..32a6eebceb1ecf4f6beacdfb717dc2669fa05f8c 100644 (file)
--- a/src/tcp.c
+++ b/src/tcp.c
@@ -1112,9 +1112,9 @@ tcp_server_done(void)
   tvh_pipe_close(&tcp_server_pipe);
   tvhpoll_destroy(tcp_server_poll);
   
-  t = getfastmonoclock();
+  t = mdispatch_clock;
   while (LIST_FIRST(&tcp_server_active) != NULL) {
-    if (t + sec2mono(5) < getfastmonoclock())
+    if (t + sec2mono(5) < mdispatch_clock)
       tvhtrace("tcp", "tcp server %p active too long", LIST_FIRST(&tcp_server_active));
     tvh_safe_usleep(20000);
   }
index e23430f283f2626c66e2c6ff9c520393d1fab099..6e7e35e36ee792053cc78c7dae35020a1d8d6c30 100644 (file)
@@ -396,8 +396,8 @@ http_stream_run(http_connection_t *hc, profile_chain_t *prch,
 
         if (hc->hc_no_output) {
           streaming_msg_free(sm);
-          mono = getfastmonoclock() + sec2mono(2);
-          while (getfastmonoclock() < mono) {
+          mono = mdispatch_clock + sec2mono(2);
+          while (mdispatch_clock < mono) {
             if (tcp_socket_dead(hc->hc_fd))
               break;
             tvh_safe_usleep(50000);