mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-26 12:27:52 +00:00
Use monotonic time when calculating the update interval (fixes sf.net #2970255)
when the system clock is moved backwards, the update interval would be calculated incorrectly. If it was moved back far enough, conky would use 100% cpu. Conky now uses monotonic clock to prevent this. If it turns out to be unsupported on some platform, an appropriate fallback can be added. problem reported by norsetto
This commit is contained in:
parent
e6088bcfe2
commit
ccc50cef48
@ -37,7 +37,7 @@
|
||||
#include "timeinfo.h"
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
@ -92,10 +92,10 @@ int update_uname(void)
|
||||
|
||||
double get_time(void)
|
||||
{
|
||||
struct timeval tv;
|
||||
struct timespec tv;
|
||||
|
||||
gettimeofday(&tv, 0);
|
||||
return tv.tv_sec + (tv.tv_usec / 1000000.0);
|
||||
clock_gettime(CLOCK_MONOTONIC, &tv);
|
||||
return tv.tv_sec + (tv.tv_nsec * 1e-9);
|
||||
}
|
||||
|
||||
/* Converts '~/...' paths to '/home/blah/...' assumes that 'dest' is at least
|
||||
|
Loading…
Reference in New Issue
Block a user