[Spice-commits] 2 commits - server/red-channel-client.c
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Dec 4 16:28:49 UTC 2019
server/red-channel-client.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
New commits:
commit cff9d951aaf1d01ac9d4bac5829ffda1f6141162
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Thu Nov 14 15:18:29 2019 +0000
red-channel-client: Always enable latency monitor to keep tcp connection alive
Create some traffic on the connection to avoid potential timeout
on some proxies implementation which require some TCP data traffic.
The timeout used by default is quite big (5 minutes) to reduce network
traffic.
In case connectivity monitoring is enabled or latency monitor is
requested the timeout is reduced to the old default.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Uri Lublin <uril at redhat.com>
diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index 82554abf..beb3a9a4 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -203,6 +203,7 @@ enum {
};
#define PING_TEST_TIMEOUT_MS (MSEC_PER_SEC * 15)
+#define PING_TEST_LONG_TIMEOUT_MS (MSEC_PER_SEC * 60 * 5)
#define PING_TEST_IDLE_NET_TIMEOUT_MS (MSEC_PER_SEC / 10)
typedef struct RedEmptyMsgPipeItem {
@@ -784,11 +785,13 @@ void red_channel_client_start_connectivity_monitoring(RedChannelClient *rcc, uin
if (rcc->priv->latency_monitor.timer == NULL) {
rcc->priv->latency_monitor.timer = core->timer_add(
core, red_channel_client_ping_timer, rcc);
- if (!red_client_during_migrate_at_target(rcc->priv->client)) {
- red_channel_client_start_ping_timer(rcc, PING_TEST_IDLE_NET_TIMEOUT_MS);
- }
rcc->priv->latency_monitor.roundtrip = -1;
- rcc->priv->latency_monitor.timeout = PING_TEST_TIMEOUT_MS;
+ } else {
+ red_channel_client_cancel_ping_timer(rcc);
+ }
+ rcc->priv->latency_monitor.timeout = PING_TEST_TIMEOUT_MS;
+ if (!red_client_during_migrate_at_target(rcc->priv->client)) {
+ red_channel_client_start_ping_timer(rcc, PING_TEST_IDLE_NET_TIMEOUT_MS);
}
if (rcc->priv->connectivity_monitor.timer == NULL) {
rcc->priv->connectivity_monitor.state = CONNECTIVITY_STATE_CONNECTED;
@@ -924,8 +927,7 @@ static gboolean red_channel_client_initable_init(GInitable *initable,
red_channel_client_event,
self);
- if (self->priv->monitor_latency
- && red_stream_get_family(self->priv->stream) != AF_UNIX) {
+ if (red_stream_get_family(self->priv->stream) != AF_UNIX) {
self->priv->latency_monitor.timer =
core->timer_add(core, red_channel_client_ping_timer, self);
@@ -934,7 +936,8 @@ static gboolean red_channel_client_initable_init(GInitable *initable,
PING_TEST_IDLE_NET_TIMEOUT_MS);
}
self->priv->latency_monitor.roundtrip = -1;
- self->priv->latency_monitor.timeout = PING_TEST_TIMEOUT_MS;
+ self->priv->latency_monitor.timeout =
+ self->priv->monitor_latency ? PING_TEST_TIMEOUT_MS : PING_TEST_LONG_TIMEOUT_MS;
}
red_channel_add_client(self->priv->channel, self);
commit 07200c8c1dfe2546f366d031bbb395100d97780e
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Thu Nov 14 15:18:29 2019 +0000
red-channel-client: Allows to change timeout for latency_monitor
This is a preparatory patch.
The "latency_monitor" feature allows to measure the latency of a
specific channel client.
Currently the measure is attempted every PING_TEST_TIMEOUT_MS which
is a constant.
To be able to use a different frequency allows to change this for every
channel client.
This feature will be also used to create some traffic on the connection
to allows some sort of keep-alive to overcome some proxy implementation
which requires some TCP data traffic.
This fixes https://bugzilla.redhat.com/show_bug.cgi?id=1719736.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Uri Lublin <uril at redhat.com>
diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index c0b2e735..82554abf 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -78,6 +78,7 @@ typedef struct RedChannelClientLatencyMonitor {
QosPingState state;
uint64_t last_pong_time;
SpiceTimer *timer;
+ uint32_t timeout;
uint32_t id;
bool tcp_nodelay;
bool warmup_was_sent;
@@ -249,8 +250,8 @@ static void red_channel_client_restart_ping_timer(RedChannelClient *rcc)
}
passed = (spice_get_monotonic_time_ns() - rcc->priv->latency_monitor.last_pong_time) / NSEC_PER_MILLISEC;
timeout = PING_TEST_IDLE_NET_TIMEOUT_MS;
- if (passed < PING_TEST_TIMEOUT_MS) {
- timeout += PING_TEST_TIMEOUT_MS - passed;
+ if (passed < rcc->priv->latency_monitor.timeout) {
+ timeout += rcc->priv->latency_monitor.timeout - passed;
}
red_channel_client_start_ping_timer(rcc, timeout);
@@ -787,6 +788,7 @@ void red_channel_client_start_connectivity_monitoring(RedChannelClient *rcc, uin
red_channel_client_start_ping_timer(rcc, PING_TEST_IDLE_NET_TIMEOUT_MS);
}
rcc->priv->latency_monitor.roundtrip = -1;
+ rcc->priv->latency_monitor.timeout = PING_TEST_TIMEOUT_MS;
}
if (rcc->priv->connectivity_monitor.timer == NULL) {
rcc->priv->connectivity_monitor.state = CONNECTIVITY_STATE_CONNECTED;
@@ -932,6 +934,7 @@ static gboolean red_channel_client_initable_init(GInitable *initable,
PING_TEST_IDLE_NET_TIMEOUT_MS);
}
self->priv->latency_monitor.roundtrip = -1;
+ self->priv->latency_monitor.timeout = PING_TEST_TIMEOUT_MS;
}
red_channel_add_client(self->priv->channel, self);
@@ -1392,7 +1395,7 @@ static void red_channel_client_handle_pong(RedChannelClient *rcc, SpiceMsgPing *
rcc->priv->latency_monitor.last_pong_time = now;
rcc->priv->latency_monitor.state = PING_STATE_NONE;
- red_channel_client_start_ping_timer(rcc, PING_TEST_TIMEOUT_MS);
+ red_channel_client_start_ping_timer(rcc, rcc->priv->latency_monitor.timeout);
}
static void red_channel_client_handle_migrate_flush_mark(RedChannelClient *rcc)
More information about the Spice-commits
mailing list