]> 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:00 +0000 (11:33 +0200)
src/main.c
src/tvhlog.h
src/wrappers.c

index 5ef84bf2dd42adabb5a1d20a7606c68ca1779d84..c47f78229beee37a50856af6d926046cccff3573 100644 (file)
@@ -483,7 +483,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 */
+  }
+}
 
 /**
  *
@@ -501,14 +517,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 2b789d82880559e2aa2bf3acf0bba97f7edfded4..4a4e958d38c751f4bae5c8be1f5b02bd9fe7c320 100644 (file)
@@ -27,6 +27,7 @@
 #endif
 #include <pthread.h>
 #include <stdarg.h>
+#include <time.h>
 
 #include "atomic.h"
 #include "htsmsg.h"
@@ -128,4 +129,6 @@ static inline void tvhtrace_no_warnings(const char *fmt, ...) { (void)fmt; }
 #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 2d472f76810eb9b311f698a95c22094954bc30a4..f464e7c431982c601867cf53eb0d76bd257a3269 100644 (file)
@@ -109,6 +109,7 @@ tvh_write(int fd, const void *buf, size_t len)
         if (dispatch_clock > next)
           break;
         usleep(100);
+        dispatch_clock_update(NULL);
         continue;
       }
       break;