summaryrefslogtreecommitdiffstats
path: root/server/main_channel.c
diff options
context:
space:
mode:
authorYonit Halperin <yhalperi@redhat.com>2013-08-14 10:56:44 -0400
committerYonit Halperin <yhalperi@redhat.com>2013-08-14 13:36:30 -0400
commited1f70c6d16ff55adf73a08f063f5d7955f4c488 (patch)
treea6a87a1ef39ccbfedd99998095558c7618c6cf62 /server/main_channel.c
parentc8b808bb8211e756a5e2280da173010984b71680 (diff)
downloadspice-ed1f70c6d16ff55adf73a08f063f5d7955f4c488.tar.gz
spice-ed1f70c6d16ff55adf73a08f063f5d7955f4c488.tar.xz
spice-ed1f70c6d16ff55adf73a08f063f5d7955f4c488.zip
main_channel: monitoring client connection status
rhbz#994175 Start monitoring if the client connection is alive after completing the bit-rate test.
Diffstat (limited to 'server/main_channel.c')
-rw-r--r--server/main_channel.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/server/main_channel.c b/server/main_channel.c
index fe032a65..54718baf 100644
--- a/server/main_channel.c
+++ b/server/main_channel.c
@@ -55,6 +55,8 @@
#define PING_INTERVAL (1000 * 10)
+#define CLIENT_CONNECTIVITY_TIMEOUT (30*1000) // 30 seconds
+
static uint8_t zero_page[ZERO_BUF_SIZE] = {0};
enum {
@@ -201,16 +203,20 @@ RedClient *main_channel_get_client_by_link_id(MainChannel *main_chan, uint32_t c
static int main_channel_client_push_ping(MainChannelClient *mcc, int size);
-void main_channel_client_start_net_test(MainChannelClient *mcc)
+void main_channel_client_start_net_test(MainChannelClient *mcc, int test_rate)
{
if (!mcc || mcc->net_test_id) {
return;
}
- if (main_channel_client_push_ping(mcc, NET_TEST_WARMUP_BYTES)
- && main_channel_client_push_ping(mcc, 0)
- && main_channel_client_push_ping(mcc, NET_TEST_BYTES)) {
- mcc->net_test_id = mcc->ping_id - 2;
- mcc->net_test_stage = NET_TEST_STAGE_WARMUP;
+ if (test_rate) {
+ if (main_channel_client_push_ping(mcc, NET_TEST_WARMUP_BYTES)
+ && main_channel_client_push_ping(mcc, 0)
+ && main_channel_client_push_ping(mcc, NET_TEST_BYTES)) {
+ mcc->net_test_id = mcc->ping_id - 2;
+ mcc->net_test_stage = NET_TEST_STAGE_WARMUP;
+ }
+ } else {
+ red_channel_client_start_connectivity_monitoring(&mcc->base, CLIENT_CONNECTIVITY_TIMEOUT);
}
}
@@ -970,6 +976,8 @@ static int main_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, uint
spice_printerr("net test: invalid values, latency %" PRIu64
" roundtrip %" PRIu64 ". assuming high"
"bandwidth", mcc->latency, roundtrip);
+ red_channel_client_start_connectivity_monitoring(&mcc->base,
+ CLIENT_CONNECTIVITY_TIMEOUT);
break;
}
mcc->bitrate_per_sec = (uint64_t)(NET_TEST_BYTES * 8) * 1000000
@@ -980,6 +988,8 @@ static int main_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, uint
mcc->bitrate_per_sec,
(double)mcc->bitrate_per_sec / 1024 / 1024,
main_channel_client_is_low_bandwidth(mcc) ? " LOW BANDWIDTH" : "");
+ red_channel_client_start_connectivity_monitoring(&mcc->base,
+ CLIENT_CONNECTIVITY_TIMEOUT);
break;
default:
spice_printerr("invalid net test stage, ping id %d test id %d stage %d",
@@ -989,6 +999,11 @@ static int main_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, uint
mcc->net_test_stage = NET_TEST_STAGE_INVALID;
}
break;
+ } else {
+ /*
+ * channel client monitors the connectivity using ping-pong messages
+ */
+ red_channel_client_handle_message(rcc, size, type, message);
}
#ifdef RED_STATISTICS
reds_update_stat_value(roundtrip);