Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
epggrab: recode previous commit using pthread_cond_timedwait
  • Loading branch information
perexg committed Nov 24, 2015
1 parent 9c60087 commit 9db2d7a
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/epggrab.c
Expand Up @@ -92,16 +92,22 @@ static void* _epggrab_internal_thread ( void* p )

/* Setup timeout */
ts.tv_nsec = 0;
time(&ts.tv_sec);
ts.tv_sec = time(NULL) + 120;

/* Time for other jobs */
t = dispatch_clock + 120;
while (epggrab_running) {
if (t < dispatch_clock)
break;
usleep(200000);
pthread_mutex_lock(&epggrab_mutex);
err = ETIMEDOUT;
while (epggrab_running) {
err = pthread_cond_timedwait(&epggrab_cond, &epggrab_mutex, &ts);
if (err == ETIMEDOUT) break;
}
pthread_mutex_unlock(&epggrab_mutex);
if (err == ETIMEDOUT) break;
}

time(&ts.tv_sec);

while (epggrab_running) {

/* Check for config change */
Expand Down

0 comments on commit 9db2d7a

Please sign in to comment.