Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix tvh_write() endless loop
  • Loading branch information
perexg committed Oct 1, 2015
1 parent 4b014d4 commit bfe6bd5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/main.c
Expand Up @@ -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 */
}
}

/**
*
Expand All @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/tvhlog.h
Expand Up @@ -27,6 +27,7 @@
#endif
#include <pthread.h>
#include <stdarg.h>
#include <time.h>

#include "atomic.h"
#include "htsmsg.h"
Expand Down Expand Up @@ -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__ */
1 change: 1 addition & 0 deletions src/wrappers.c
Expand Up @@ -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;
Expand Down

0 comments on commit bfe6bd5

Please sign in to comment.