diff --git a/aucat/file.c b/aucat/file.c index df5b87e..1ecb369 100644 --- a/aucat/file.c +++ b/aucat/file.c @@ -297,7 +297,8 @@ file_poll(void) struct file *f, *fnext; struct aproc *p; struct timespec ts; - long delta_nsec; + long long delta_nsec; + int res; if (LIST_EMPTY(&file_list)) { #ifdef DEBUG @@ -346,20 +347,25 @@ file_poll(void) dbg_puts("\n"); } #endif - if (nfds > 0) { - if (poll(pfds, nfds, -1) < 0) { - if (errno == EINTR) - return 1; - err(1, "file_poll: poll failed"); - } - clock_gettime(CLOCK_MONOTONIC, &ts); - delta_nsec = 1000000000L * (ts.tv_sec - file_ts.tv_sec); - delta_nsec += ts.tv_nsec - file_ts.tv_nsec; - if (delta_nsec > 0) { - file_ts = ts; + res = poll(pfds, nfds, -1); + if (res < 0 && errno != EINTR) + err(1, "poll"); + clock_gettime(CLOCK_MONOTONIC, &ts); + delta_nsec = 1000000000LL * (ts.tv_sec - file_ts.tv_sec); + delta_nsec += ts.tv_nsec - file_ts.tv_nsec; + if (delta_nsec > 0) { + file_ts = ts; + if (delta_nsec < 1000000000LL) timo_update(delta_nsec / 1000); + else { +#ifdef DEBUG + dbg_puts("ignored huge clock delta\n"); +#endif } } + if (res <= 0) + return 1; + f = LIST_FIRST(&file_list); while (f != NULL) { if (f->pfd == NULL) {