summaryrefslogtreecommitdiff
path: root/toxcore/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/util.c')
-rw-r--r--toxcore/util.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/toxcore/util.c b/toxcore/util.c
index 07db57f0..58f0336c 100644
--- a/toxcore/util.c
+++ b/toxcore/util.c
@@ -36,10 +36,14 @@
36 36
37/* don't call into system billions of times for no reason */ 37/* don't call into system billions of times for no reason */
38static uint64_t unix_time_value; 38static uint64_t unix_time_value;
39static uint64_t unix_base_time_value;
39 40
40void unix_time_update() 41void unix_time_update()
41{ 42{
42 unix_time_value = (uint64_t)time(NULL); 43 if (unix_base_time_value == 0)
44 unix_base_time_value = ((uint64_t)time(NULL) - (current_time_monotonic() / 1000ULL));
45
46 unix_time_value = (current_time_monotonic() / 1000ULL) + unix_base_time_value;
43} 47}
44 48
45uint64_t unix_time() 49uint64_t unix_time()
@@ -49,7 +53,7 @@ uint64_t unix_time()
49 53
50int is_timeout(uint64_t timestamp, uint64_t timeout) 54int is_timeout(uint64_t timestamp, uint64_t timeout)
51{ 55{
52 return timestamp + timeout <= unix_time_value; 56 return timestamp + timeout <= unix_time();
53} 57}
54 58
55 59