1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-26 12:27:52 +00:00

Fix sleep calculation for >1s sleeps. (#543)

The second portion of the time was being discarded, with only the nanos being
respected. This should fix #539.
This commit is contained in:
Brenden Matthews 2018-08-02 11:05:47 -04:00 committed by GitHub
parent fa5e56720f
commit 71cfbff645
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2389,10 +2389,13 @@ static void main_loop() {
} }
} else { } else {
#endif /* BUILD_X11 */ #endif /* BUILD_X11 */
struct timespec ts1, ts2; struct timespec req, rem;
ts1.tv_sec = 0; auto time_to_sleep = next_update_time - get_time();
ts1.tv_nsec = (next_update_time - get_time()) * 1000000000L; auto seconds = (time_t)std::floor(time_to_sleep);
nanosleep(&ts1, &ts2); auto nanos = (time_to_sleep - seconds) * 1000000000L;
req.tv_sec = seconds;
req.tv_nsec = nanos;
nanosleep(&req, &rem);
update_text(); update_text();
draw_stuff(); draw_stuff();
#ifdef BUILD_NCURSES #ifdef BUILD_NCURSES