|
|
20333d |
From 3d1c72b6da63f24aeaae45ec7681826520c1d404 Mon Sep 17 00:00:00 2001
|
|
|
20333d |
From: Yonit Halperin <yhalperi@redhat.com>
|
|
|
20333d |
Date: Wed, 14 Aug 2013 10:56:44 -0400
|
|
|
20333d |
Subject: [PATCH] main_channel: monitoring client connection status
|
|
|
20333d |
|
|
|
20333d |
rhbz#994175
|
|
|
20333d |
|
|
|
20333d |
Start monitoring if the client connection is alive after completing
|
|
|
20333d |
the bit-rate test.
|
|
|
20333d |
|
|
|
20333d |
https://bugzilla.redhat.com/show_bug.cgi?id=1016790
|
|
|
20333d |
(cherry picked from commit ed1f70c6d16ff55adf73a08f063f5d7955f4c488)
|
|
|
20333d |
---
|
|
|
20333d |
server/main_channel.c | 27 +++++++++++++++++++++------
|
|
|
20333d |
server/main_channel.h | 2 +-
|
|
|
20333d |
server/reds.c | 3 +--
|
|
|
20333d |
3 files changed, 23 insertions(+), 9 deletions(-)
|
|
|
20333d |
|
|
|
20333d |
diff --git a/server/main_channel.c b/server/main_channel.c
|
|
|
20333d |
index fe032a6..54718ba 100644
|
|
|
20333d |
--- a/server/main_channel.c
|
|
|
20333d |
+++ b/server/main_channel.c
|
|
|
20333d |
@@ -55,6 +55,8 @@
|
|
|
20333d |
|
|
|
20333d |
#define PING_INTERVAL (1000 * 10)
|
|
|
20333d |
|
|
|
20333d |
+#define CLIENT_CONNECTIVITY_TIMEOUT (30*1000) // 30 seconds
|
|
|
20333d |
+
|
|
|
20333d |
static uint8_t zero_page[ZERO_BUF_SIZE] = {0};
|
|
|
20333d |
|
|
|
20333d |
enum {
|
|
|
20333d |
@@ -201,16 +203,20 @@ RedClient *main_channel_get_client_by_link_id(MainChannel *main_chan, uint32_t c
|
|
|
20333d |
|
|
|
20333d |
static int main_channel_client_push_ping(MainChannelClient *mcc, int size);
|
|
|
20333d |
|
|
|
20333d |
-void main_channel_client_start_net_test(MainChannelClient *mcc)
|
|
|
20333d |
+void main_channel_client_start_net_test(MainChannelClient *mcc, int test_rate)
|
|
|
20333d |
{
|
|
|
20333d |
if (!mcc || mcc->net_test_id) {
|
|
|
20333d |
return;
|
|
|
20333d |
}
|
|
|
20333d |
- if (main_channel_client_push_ping(mcc, NET_TEST_WARMUP_BYTES)
|
|
|
20333d |
- && main_channel_client_push_ping(mcc, 0)
|
|
|
20333d |
- && main_channel_client_push_ping(mcc, NET_TEST_BYTES)) {
|
|
|
20333d |
- mcc->net_test_id = mcc->ping_id - 2;
|
|
|
20333d |
- mcc->net_test_stage = NET_TEST_STAGE_WARMUP;
|
|
|
20333d |
+ if (test_rate) {
|
|
|
20333d |
+ if (main_channel_client_push_ping(mcc, NET_TEST_WARMUP_BYTES)
|
|
|
20333d |
+ && main_channel_client_push_ping(mcc, 0)
|
|
|
20333d |
+ && main_channel_client_push_ping(mcc, NET_TEST_BYTES)) {
|
|
|
20333d |
+ mcc->net_test_id = mcc->ping_id - 2;
|
|
|
20333d |
+ mcc->net_test_stage = NET_TEST_STAGE_WARMUP;
|
|
|
20333d |
+ }
|
|
|
20333d |
+ } else {
|
|
|
20333d |
+ red_channel_client_start_connectivity_monitoring(&mcc->base, CLIENT_CONNECTIVITY_TIMEOUT);
|
|
|
20333d |
}
|
|
|
20333d |
}
|
|
|
20333d |
|
|
|
20333d |
@@ -970,6 +976,8 @@ static int main_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, uint
|
|
|
20333d |
spice_printerr("net test: invalid values, latency %" PRIu64
|
|
|
20333d |
" roundtrip %" PRIu64 ". assuming high"
|
|
|
20333d |
"bandwidth", mcc->latency, roundtrip);
|
|
|
20333d |
+ red_channel_client_start_connectivity_monitoring(&mcc->base,
|
|
|
20333d |
+ CLIENT_CONNECTIVITY_TIMEOUT);
|
|
|
20333d |
break;
|
|
|
20333d |
}
|
|
|
20333d |
mcc->bitrate_per_sec = (uint64_t)(NET_TEST_BYTES * 8) * 1000000
|
|
|
20333d |
@@ -980,6 +988,8 @@ static int main_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, uint
|
|
|
20333d |
mcc->bitrate_per_sec,
|
|
|
20333d |
(double)mcc->bitrate_per_sec / 1024 / 1024,
|
|
|
20333d |
main_channel_client_is_low_bandwidth(mcc) ? " LOW BANDWIDTH" : "");
|
|
|
20333d |
+ red_channel_client_start_connectivity_monitoring(&mcc->base,
|
|
|
20333d |
+ CLIENT_CONNECTIVITY_TIMEOUT);
|
|
|
20333d |
break;
|
|
|
20333d |
default:
|
|
|
20333d |
spice_printerr("invalid net test stage, ping id %d test id %d stage %d",
|
|
|
20333d |
@@ -989,6 +999,11 @@ static int main_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, uint
|
|
|
20333d |
mcc->net_test_stage = NET_TEST_STAGE_INVALID;
|
|
|
20333d |
}
|
|
|
20333d |
break;
|
|
|
20333d |
+ } else {
|
|
|
20333d |
+ /*
|
|
|
20333d |
+ * channel client monitors the connectivity using ping-pong messages
|
|
|
20333d |
+ */
|
|
|
20333d |
+ red_channel_client_handle_message(rcc, size, type, message);
|
|
|
20333d |
}
|
|
|
20333d |
#ifdef RED_STATISTICS
|
|
|
20333d |
reds_update_stat_value(roundtrip);
|
|
|
20333d |
diff --git a/server/main_channel.h b/server/main_channel.h
|
|
|
20333d |
index 27367a4..29eb8d4 100644
|
|
|
20333d |
--- a/server/main_channel.h
|
|
|
20333d |
+++ b/server/main_channel.h
|
|
|
20333d |
@@ -54,7 +54,7 @@ void main_channel_push_agent_disconnected(MainChannel *main_chan);
|
|
|
20333d |
void main_channel_client_push_agent_tokens(MainChannelClient *mcc, uint32_t num_tokens);
|
|
|
20333d |
void main_channel_client_push_agent_data(MainChannelClient *mcc, uint8_t* data, size_t len,
|
|
|
20333d |
spice_marshaller_item_free_func free_data, void *opaque);
|
|
|
20333d |
-void main_channel_client_start_net_test(MainChannelClient *mcc);
|
|
|
20333d |
+void main_channel_client_start_net_test(MainChannelClient *mcc, int test_rate);
|
|
|
20333d |
// TODO: huge. Consider making a reds_* interface for these functions
|
|
|
20333d |
// and calling from main.
|
|
|
20333d |
void main_channel_push_init(MainChannelClient *mcc, int display_channels_hint,
|
|
|
20333d |
diff --git a/server/reds.c b/server/reds.c
|
|
|
20333d |
index f9f185d..7b7f262 100644
|
|
|
20333d |
--- a/server/reds.c
|
|
|
20333d |
+++ b/server/reds.c
|
|
|
20333d |
@@ -1718,11 +1718,10 @@ static void reds_handle_main_link(RedLinkInfo *link)
|
|
|
20333d |
main_channel_push_name(mcc, spice_name);
|
|
|
20333d |
if (spice_uuid_is_set)
|
|
|
20333d |
main_channel_push_uuid(mcc, spice_uuid);
|
|
|
20333d |
-
|
|
|
20333d |
- main_channel_client_start_net_test(mcc);
|
|
|
20333d |
} else {
|
|
|
20333d |
reds_mig_target_client_add(client);
|
|
|
20333d |
}
|
|
|
20333d |
+ main_channel_client_start_net_test(mcc, !mig_target);
|
|
|
20333d |
}
|
|
|
20333d |
|
|
|
20333d |
#define RED_MOUSE_STATE_TO_LOCAL(state) \
|