Blame SOURCES/0030-red-channel-client-Allows-to-change-timeout-for-late.patch

6ba27a
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
6ba27a
From: Frediano Ziglio <fziglio@redhat.com>
6ba27a
Date: Thu, 14 Nov 2019 15:18:29 +0000
6ba27a
Subject: [PATCH 1/2] red-channel-client: Allows to change timeout for
6ba27a
 latency_monitor
6ba27a
6ba27a
This is a preparatory patch.
6ba27a
The "latency_monitor" feature allows to measure the latency of a
6ba27a
specific channel client.
6ba27a
Currently the measure is attempted every PING_TEST_TIMEOUT_MS which
6ba27a
is a constant.
6ba27a
To be able to use a different frequency allows to change this for every
6ba27a
channel client.
6ba27a
This feature will be also used to create some traffic on the connection
6ba27a
to allows some sort of keep-alive to overcome some proxy implementation
6ba27a
which requires some TCP data traffic.
6ba27a
6ba27a
This fixes https://bugzilla.redhat.com/show_bug.cgi?id=1719736.
6ba27a
6ba27a
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
6ba27a
---
6ba27a
 server/red-channel-client.c | 9 ++++++---
6ba27a
 1 file changed, 6 insertions(+), 3 deletions(-)
6ba27a
6ba27a
diff --git a/server/red-channel-client.c b/server/red-channel-client.c
6ba27a
index a707dbcb..3cc6a709 100644
6ba27a
--- a/server/red-channel-client.c
6ba27a
+++ b/server/red-channel-client.c
6ba27a
@@ -78,6 +78,7 @@ typedef struct RedChannelClientLatencyMonitor {
6ba27a
     QosPingState state;
6ba27a
     uint64_t last_pong_time;
6ba27a
     SpiceTimer *timer;
6ba27a
+    uint32_t timeout;
6ba27a
     uint32_t id;
6ba27a
     bool tcp_nodelay;
6ba27a
     bool warmup_was_sent;
6ba27a
@@ -262,8 +263,8 @@ static void red_channel_client_restart_ping_timer(RedChannelClient *rcc)
6ba27a
     }
6ba27a
     passed = (spice_get_monotonic_time_ns() - rcc->priv->latency_monitor.last_pong_time) / NSEC_PER_MILLISEC;
6ba27a
     timeout = PING_TEST_IDLE_NET_TIMEOUT_MS;
6ba27a
-    if (passed  < PING_TEST_TIMEOUT_MS) {
6ba27a
-        timeout += PING_TEST_TIMEOUT_MS - passed;
6ba27a
+    if (passed  < rcc->priv->latency_monitor.timeout) {
6ba27a
+        timeout += rcc->priv->latency_monitor.timeout - passed;
6ba27a
     }
6ba27a
 
6ba27a
     red_channel_client_start_ping_timer(rcc, timeout);
6ba27a
@@ -811,6 +812,7 @@ void red_channel_client_start_connectivity_monitoring(RedChannelClient *rcc, uin
6ba27a
             red_channel_client_start_ping_timer(rcc, PING_TEST_IDLE_NET_TIMEOUT_MS);
6ba27a
         }
6ba27a
         rcc->priv->latency_monitor.roundtrip = -1;
6ba27a
+        rcc->priv->latency_monitor.timeout = PING_TEST_TIMEOUT_MS;
6ba27a
     }
6ba27a
     if (rcc->priv->connectivity_monitor.timer == NULL) {
6ba27a
         rcc->priv->connectivity_monitor.state = CONNECTIVITY_STATE_CONNECTED;
6ba27a
@@ -956,6 +958,7 @@ static gboolean red_channel_client_initable_init(GInitable *initable,
6ba27a
                                                 PING_TEST_IDLE_NET_TIMEOUT_MS);
6ba27a
         }
6ba27a
         self->priv->latency_monitor.roundtrip = -1;
6ba27a
+        self->priv->latency_monitor.timeout = PING_TEST_TIMEOUT_MS;
6ba27a
     }
6ba27a
 
6ba27a
     red_channel_add_client(self->priv->channel, self);
6ba27a
@@ -1394,7 +1397,7 @@ static void red_channel_client_handle_pong(RedChannelClient *rcc, SpiceMsgPing *
6ba27a
 
6ba27a
     rcc->priv->latency_monitor.last_pong_time = now;
6ba27a
     rcc->priv->latency_monitor.state = PING_STATE_NONE;
6ba27a
-    red_channel_client_start_ping_timer(rcc, PING_TEST_TIMEOUT_MS);
6ba27a
+    red_channel_client_start_ping_timer(rcc, rcc->priv->latency_monitor.timeout);
6ba27a
 }
6ba27a
 
6ba27a
 static void red_channel_client_handle_migrate_flush_mark(RedChannelClient *rcc)