GUACAMOLE-239: When available, use CLOCK_MONOTONIC to prevent backwards running time
This commit is contained in:
parent
da7b77d2ec
commit
ddc1aa0b5f
@ -33,9 +33,13 @@ guac_timestamp guac_timestamp_current() {
|
|||||||
|
|
||||||
struct timespec current;
|
struct timespec current;
|
||||||
|
|
||||||
/* Get current time */
|
/* Get current time, monotonically increasing */
|
||||||
|
#ifdef CLOCK_MONOTONIC
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, ¤t);
|
||||||
|
#else
|
||||||
clock_gettime(CLOCK_REALTIME, ¤t);
|
clock_gettime(CLOCK_REALTIME, ¤t);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Calculate milliseconds */
|
/* Calculate milliseconds */
|
||||||
return (guac_timestamp) current.tv_sec * 1000 + current.tv_nsec / 1000000;
|
return (guac_timestamp) current.tv_sec * 1000 + current.tv_nsec / 1000000;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user