diff options
author | Daiki Ueno <dueno@src.gnome.org> | 2018-03-01 17:06:29 +0100 |
---|---|---|
committer | Daiki Ueno <dueno@src.gnome.org> | 2018-03-02 10:29:54 +0100 |
commit | 1864f1e14bfd41a51fac8324cac8cbd2b31cc3cc (patch) | |
tree | 1c43d85db9899ee07fe740366f9be871ab21343f /pkcs11/gkm | |
parent | 5d8326eaf1ebce1cde2ee797c03f261da3159aae (diff) | |
download | gnome-keyring-1864f1e14bfd41a51fac8324cac8cbd2b31cc3cc.tar.gz |
gkm-timer: Use monotonic time exclusively
Previously, it used g_get_real_time(), g_get_current_time(), and
g_get_monotonic_time() in a mixed manner. To measure the elapsed
time, it would be sufficient to use g_get_monotonic_time() only.
https://bugzilla.gnome.org/show_bug.cgi?id=791932
Diffstat (limited to 'pkcs11/gkm')
-rw-r--r-- | pkcs11/gkm/gkm-timer.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/pkcs11/gkm/gkm-timer.c b/pkcs11/gkm/gkm-timer.c index 918b5b30..5052d6d8 100644 --- a/pkcs11/gkm/gkm-timer.c +++ b/pkcs11/gkm/gkm-timer.c @@ -27,7 +27,7 @@ #include <glib.h> struct _GkmTimer { - glong when; + gint64 when; GMutex *mutex; gpointer identifier; GkmTimerFunc callback; @@ -69,8 +69,7 @@ timer_thread_func (gpointer unused) } if (timer->when) { - gint64 when = ((gint64)timer->when) * G_TIME_SPAN_SECOND; - gint64 offset = when - g_get_real_time (); + gint64 offset = timer->when - g_get_monotonic_time (); if (offset > 0) { g_cond_wait_until (timer_cond, &timer_mutex, g_get_monotonic_time () + offset); continue; @@ -165,15 +164,12 @@ GkmTimer* gkm_timer_start (GkmModule *module, glong seconds, GkmTimerFunc callback, gpointer user_data) { GkmTimer *timer; - GTimeVal tv; g_return_val_if_fail (callback, NULL); g_return_val_if_fail (timer_queue, NULL); - g_get_current_time (&tv); - timer = g_slice_new (GkmTimer); - timer->when = seconds + tv.tv_sec; + timer->when = g_get_monotonic_time () + seconds * G_TIME_SPAN_SECOND; timer->callback = callback; timer->user_data = user_data; |