[Spice-commits] server/main-channel-client.c server/reds.c server/utils.h

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Oct 9 14:35:20 UTC 2018


 server/main-channel-client.c |    4 ++--
 server/reds.c                |    2 +-
 server/utils.h               |    3 ++-
 3 files changed, 5 insertions(+), 4 deletions(-)

New commits:
commit 3deedc3b6b62c5caffc07e002696e5e226064436
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Tue Oct 9 09:19:22 2018 +0100

    utils: Get monotonic time in a coherent way
    
    Use a single function to get monotonic time.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/server/main-channel-client.c b/server/main-channel-client.c
index b1e5a3e8..54be9934 100644
--- a/server/main-channel-client.c
+++ b/server/main-channel-client.c
@@ -503,7 +503,7 @@ void main_channel_client_handle_pong(MainChannelClient *mcc, SpiceMsgPing *ping,
     uint64_t roundtrip;
     RedChannelClient* rcc = RED_CHANNEL_CLIENT(mcc);
 
-    roundtrip = g_get_monotonic_time() - ping->timestamp;
+    roundtrip = spice_get_monotonic_time_ns() / NSEC_PER_MICROSEC - ping->timestamp;
 
     if (ping->id != mcc->priv->net_test_id) {
         /*
@@ -749,7 +749,7 @@ static void main_channel_marshall_ping(RedChannelClient *rcc,
 
     red_channel_client_init_send_data(rcc, SPICE_MSG_PING);
     ping.id = main_channel_client_next_ping_id(mcc);
-    ping.timestamp = g_get_monotonic_time();
+    ping.timestamp = spice_get_monotonic_time_ns() / NSEC_PER_MICROSEC;
     spice_marshall_msg_ping(m, &ping);
 
     while (size_left > 0) {
diff --git a/server/reds.c b/server/reds.c
index bdd6a45c..bff5b68e 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3004,7 +3004,7 @@ static void migrate_timeout(void *opaque)
 
 uint32_t reds_get_mm_time(void)
 {
-    return g_get_monotonic_time() / 1000;
+    return spice_get_monotonic_time_ns() / NSEC_PER_MILLISEC;
 }
 
 void reds_enable_mm_time(RedsState *reds)
diff --git a/server/utils.h b/server/utils.h
index 07878539..57d89bee 100644
--- a/server/utils.h
+++ b/server/utils.h
@@ -54,8 +54,9 @@ typedef int64_t red_time_t;
 
 #define NSEC_PER_SEC      1000000000LL
 #define NSEC_PER_MILLISEC 1000000LL
+#define NSEC_PER_MICROSEC 1000
 
-/* FIXME: consider g_get_monotonic_time (), but in microseconds */
+/* g_get_monotonic_time() does not have enough precision */
 static inline red_time_t spice_get_monotonic_time_ns(void)
 {
     struct timespec time;


More information about the Spice-commits mailing list