From: Jaroslav Kysela Date: Thu, 1 Oct 2015 09:33:00 +0000 (+0200) Subject: fix tvh_write() endless loop X-Git-Tag: v4.0.7~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=675dbc75646b326c6909e6a3330367d54a2bc7ae;p=thirdparty%2Ftvheadend.git fix tvh_write() endless loop --- diff --git a/src/main.c b/src/main.c index ccd5168c9..087600ae6 100644 --- a/src/main.c +++ b/src/main.c @@ -480,7 +480,23 @@ show_usage exit(0); } - +/** + * + */ +void +dispatch_clock_update(struct timespec *ts) +{ + struct timespec ts1; + if (ts == NULL) + ts = &ts1; + clock_gettime(CLOCK_REALTIME, ts); + + /* 1sec stuff */ + if (ts->tv_sec > dispatch_clock) { + dispatch_clock = ts->tv_sec; + comet_flush(); /* Flush idle comet mailboxes */ + } +} /** * @@ -498,14 +514,7 @@ mainloop(void) #endif while(tvheadend_running) { - clock_gettime(CLOCK_REALTIME, &ts); - - /* 1sec stuff */ - if (ts.tv_sec > dispatch_clock) { - dispatch_clock = ts.tv_sec; - - comet_flush(); /* Flush idle comet mailboxes */ - } + dispatch_clock_update(&ts); /* Global timers */ pthread_mutex_lock(&global_lock); diff --git a/src/tvhlog.h b/src/tvhlog.h index c6b1acf7c..864cc8d71 100644 --- a/src/tvhlog.h +++ b/src/tvhlog.h @@ -27,6 +27,7 @@ #endif #include #include +#include #include "htsmsg.h" @@ -117,4 +118,6 @@ static inline int tvhlog_limit ( tvhlog_limit_t *limit, uint32_t delay ) #define tvhnotice(...) tvhlog(LOG_NOTICE, ##__VA_ARGS__) #define tvherror(...) tvhlog(LOG_ERR, ##__VA_ARGS__) +void dispatch_clock_update(struct timespec *ts); + #endif /* __TVH_LOGGING_H__ */ diff --git a/src/wrappers.c b/src/wrappers.c index 4a204a496..3fd1938a4 100644 --- a/src/wrappers.c +++ b/src/wrappers.c @@ -82,6 +82,7 @@ tvh_write(int fd, const void *buf, size_t len) if (dispatch_clock > next) break; usleep(100); + dispatch_clock_update(NULL); continue; } break;