Blame SOURCES/0031-red-channel-client-Always-enable-latency-monitor-to-.patch

903bfe
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
903bfe
From: Frediano Ziglio <fziglio@redhat.com>
903bfe
Date: Thu, 14 Nov 2019 15:18:29 +0000
903bfe
Subject: [PATCH 2/2] red-channel-client: Always enable latency monitor to keep
903bfe
 tcp connection alive
903bfe
903bfe
Create some traffic on the connection to avoid potential timeout
903bfe
on some proxies implementation which require some TCP data traffic.
903bfe
The timeout used by default is quite big (5 minutes) to reduce network
903bfe
traffic.
903bfe
In case connectivity monitoring is enabled or latency monitor is
903bfe
requested the timeout is reduced to the old default.
903bfe
903bfe
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
903bfe
---
903bfe
 server/red-channel-client.c | 18 +++++++++++-------
903bfe
 1 file changed, 11 insertions(+), 7 deletions(-)
903bfe
903bfe
diff --git a/server/red-channel-client.c b/server/red-channel-client.c
903bfe
index 3cc6a70..7be382e 100644
903bfe
--- a/server/red-channel-client.c
903bfe
+++ b/server/red-channel-client.c
903bfe
@@ -210,6 +210,7 @@ enum {
903bfe
 };
903bfe
 
903bfe
 #define PING_TEST_TIMEOUT_MS (MSEC_PER_SEC * 15)
903bfe
+#define PING_TEST_LONG_TIMEOUT_MS (MSEC_PER_SEC * 60 * 5)
903bfe
 #define PING_TEST_IDLE_NET_TIMEOUT_MS (MSEC_PER_SEC / 10)
903bfe
 
903bfe
 typedef struct RedEmptyMsgPipeItem {
903bfe
@@ -808,11 +809,13 @@ void red_channel_client_start_connectivity_monitoring(RedChannelClient *rcc, uin
903bfe
     if (rcc->priv->latency_monitor.timer == NULL) {
903bfe
         rcc->priv->latency_monitor.timer = core->timer_add(
903bfe
             core, red_channel_client_ping_timer, rcc);
903bfe
-        if (!red_client_during_migrate_at_target(rcc->priv->client)) {
903bfe
-            red_channel_client_start_ping_timer(rcc, PING_TEST_IDLE_NET_TIMEOUT_MS);
903bfe
-        }
903bfe
         rcc->priv->latency_monitor.roundtrip = -1;
903bfe
-        rcc->priv->latency_monitor.timeout = PING_TEST_TIMEOUT_MS;
903bfe
+    } else {
903bfe
+        red_channel_client_cancel_ping_timer(rcc);
903bfe
+    }
903bfe
+    rcc->priv->latency_monitor.timeout = PING_TEST_TIMEOUT_MS;
903bfe
+    if (!red_client_during_migrate_at_target(rcc->priv->client)) {
903bfe
+        red_channel_client_start_ping_timer(rcc, PING_TEST_IDLE_NET_TIMEOUT_MS);
903bfe
     }
903bfe
     if (rcc->priv->connectivity_monitor.timer == NULL) {
903bfe
         rcc->priv->connectivity_monitor.state = CONNECTIVITY_STATE_CONNECTED;
903bfe
@@ -948,8 +951,7 @@ static gboolean red_channel_client_initable_init(GInitable *initable,
903bfe
                         red_channel_client_event,
903bfe
                         self);
903bfe
 
903bfe
-    if (self->priv->monitor_latency
903bfe
-        && reds_stream_get_family(self->priv->stream) != AF_UNIX) {
903bfe
+    if (reds_stream_get_family(self->priv->stream) != AF_UNIX) {
903bfe
         self->priv->latency_monitor.timer =
903bfe
             core->timer_add(core, red_channel_client_ping_timer, self);
903bfe
 
903bfe
@@ -958,7 +960,8 @@ static gboolean red_channel_client_initable_init(GInitable *initable,
903bfe
                                                 PING_TEST_IDLE_NET_TIMEOUT_MS);
903bfe
         }
903bfe
         self->priv->latency_monitor.roundtrip = -1;
903bfe
-        self->priv->latency_monitor.timeout = PING_TEST_TIMEOUT_MS;
903bfe
+        self->priv->latency_monitor.timeout =
903bfe
+            self->priv->monitor_latency ? PING_TEST_TIMEOUT_MS : PING_TEST_LONG_TIMEOUT_MS;
903bfe
     }
903bfe
 
903bfe
     red_channel_add_client(self->priv->channel, self);