mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-01-01 04:45:37 +00:00
utils: Get monotonic time in a coherent way
Use a single function to get monotonic time. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Christophe Fergeau <cfergeau@redhat.com>
This commit is contained in:
parent
b27e0e6f0b
commit
3deedc3b6b
@ -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) {
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user