1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-26 04:17:33 +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 {
#endif /* BUILD_X11 */
struct timespec ts1, ts2;
ts1.tv_sec = 0;
ts1.tv_nsec = (next_update_time - get_time()) * 1000000000L;
nanosleep(&ts1, &ts2);
struct timespec req, rem;
auto time_to_sleep = next_update_time - get_time();
auto seconds = (time_t)std::floor(time_to_sleep);
auto nanos = (time_to_sleep - seconds) * 1000000000L;
req.tv_sec = seconds;
req.tv_nsec = nanos;
nanosleep(&req, &rem);
update_text();
draw_stuff();
#ifdef BUILD_NCURSES