]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
fix tvh_write() endless loop
authorJaroslav Kysela <perex@perex.cz>
Thu, 1 Oct 2015 09:33:00 +0000 (11:33 +0200)
committerJaroslav Kysela <perex@perex.cz>
Thu, 1 Oct 2015 09:33:07 +0000 (11:33 +0200)
src/main.c
src/tvhlog.h
src/wrappers.c

index ccd5168c907155e78f0c1762a2fe78473859e7b2..087600ae63f4965bd7fe0581a60938390ec15319 100644 (file)
@@ -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);
index c6b1acf7c57666ec4009d66e2eed2ecef93f5128..864cc8d7157501b8317d53c79746e18ad8525ec3 100644 (file)
@@ -27,6 +27,7 @@
 #endif
 #include <pthread.h>
 #include <stdarg.h>
+#include <time.h>
 
 #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__ */
index 4a204a496676980db18459e14fe82d82ece031e0..3fd1938a4903d93b8e6eabaf0fe1c4183145fa15 100644 (file)
@@ -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;