From: Jaroslav Kysela Date: Sat, 5 Mar 2016 16:08:51 +0000 (+0100) Subject: add mtimer tick thread to update mono timer 10x in one second X-Git-Tag: v4.2.1~961 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0425be74ff72801abaf47d69590d88b62a83a771;p=thirdparty%2Ftvheadend.git add mtimer tick thread to update mono timer 10x in one second --- diff --git a/src/main.c b/src/main.c index 4e84701f7..06890e910 100644 --- a/src/main.c +++ b/src/main.c @@ -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); diff --git a/src/tcp.c b/src/tcp.c index a0eb97826..32a6eebce 100644 --- 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); } diff --git a/src/webui/webui.c b/src/webui/webui.c index e23430f28..6e7e35e36 100644 --- a/src/webui/webui.c +++ b/src/webui/webui.c @@ -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);