mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2025-12-30 09:46:50 +00:00
red-channel-client: Make handle_message protected
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
parent
9ae11a3545
commit
aecbdd9e5b
@ -403,62 +403,63 @@ void main_channel_client_handle_migrate_dst_do_seamless(MainChannelClient *mcc,
|
||||
mcc->pipe_add_empty_msg(SPICE_MSG_MAIN_MIGRATE_DST_SEAMLESS_NACK);
|
||||
}
|
||||
}
|
||||
void main_channel_client_handle_pong(MainChannelClient *mcc, SpiceMsgPing *ping, uint32_t size)
|
||||
|
||||
void MainChannelClient::handle_pong(SpiceMsgPing *ping, uint32_t size)
|
||||
{
|
||||
uint64_t roundtrip;
|
||||
|
||||
roundtrip = spice_get_monotonic_time_ns() / NSEC_PER_MICROSEC - ping->timestamp;
|
||||
|
||||
if (ping->id != mcc->priv->net_test_id) {
|
||||
if (ping->id != priv->net_test_id) {
|
||||
/*
|
||||
* channel client monitors the connectivity using ping-pong messages
|
||||
*/
|
||||
mcc->RedChannelClient::handle_message(SPICE_MSGC_PONG, size, ping);
|
||||
RedChannelClient::handle_message(SPICE_MSGC_PONG, size, ping);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (mcc->priv->net_test_stage) {
|
||||
switch (priv->net_test_stage) {
|
||||
case NET_TEST_STAGE_WARMUP:
|
||||
mcc->priv->net_test_id++;
|
||||
mcc->priv->net_test_stage = NET_TEST_STAGE_LATENCY;
|
||||
mcc->priv->latency = roundtrip;
|
||||
priv->net_test_id++;
|
||||
priv->net_test_stage = NET_TEST_STAGE_LATENCY;
|
||||
priv->latency = roundtrip;
|
||||
break;
|
||||
case NET_TEST_STAGE_LATENCY:
|
||||
mcc->priv->net_test_id++;
|
||||
mcc->priv->net_test_stage = NET_TEST_STAGE_RATE;
|
||||
mcc->priv->latency = MIN(mcc->priv->latency, roundtrip);
|
||||
priv->net_test_id++;
|
||||
priv->net_test_stage = NET_TEST_STAGE_RATE;
|
||||
priv->latency = MIN(priv->latency, roundtrip);
|
||||
break;
|
||||
case NET_TEST_STAGE_RATE:
|
||||
mcc->priv->net_test_id = 0;
|
||||
if (roundtrip <= mcc->priv->latency) {
|
||||
priv->net_test_id = 0;
|
||||
if (roundtrip <= priv->latency) {
|
||||
// probably high load on client or server result with incorrect values
|
||||
red_channel_debug(mcc->get_channel(),
|
||||
red_channel_debug(get_channel(),
|
||||
"net test: invalid values, latency %" G_GUINT64_FORMAT
|
||||
" roundtrip %" G_GUINT64_FORMAT ". assuming high"
|
||||
"bandwidth", mcc->priv->latency, roundtrip);
|
||||
mcc->priv->latency = 0;
|
||||
mcc->priv->net_test_stage = NET_TEST_STAGE_INVALID;
|
||||
mcc->start_connectivity_monitoring(CLIENT_CONNECTIVITY_TIMEOUT);
|
||||
"bandwidth", priv->latency, roundtrip);
|
||||
priv->latency = 0;
|
||||
priv->net_test_stage = NET_TEST_STAGE_INVALID;
|
||||
start_connectivity_monitoring(CLIENT_CONNECTIVITY_TIMEOUT);
|
||||
break;
|
||||
}
|
||||
mcc->priv->bitrate_per_sec = (uint64_t)(NET_TEST_BYTES * 8) * 1000000
|
||||
/ (roundtrip - mcc->priv->latency);
|
||||
mcc->priv->net_test_stage = NET_TEST_STAGE_COMPLETE;
|
||||
red_channel_debug(mcc->get_channel(),
|
||||
priv->bitrate_per_sec = (uint64_t)(NET_TEST_BYTES * 8) * 1000000
|
||||
/ (roundtrip - priv->latency);
|
||||
priv->net_test_stage = NET_TEST_STAGE_COMPLETE;
|
||||
red_channel_debug(get_channel(),
|
||||
"net test: latency %f ms, bitrate %" G_GUINT64_FORMAT " bps (%f Mbps)%s",
|
||||
(double)mcc->priv->latency / 1000,
|
||||
mcc->priv->bitrate_per_sec,
|
||||
(double)mcc->priv->bitrate_per_sec / 1024 / 1024,
|
||||
main_channel_client_is_low_bandwidth(mcc) ? " LOW BANDWIDTH" : "");
|
||||
mcc->start_connectivity_monitoring(CLIENT_CONNECTIVITY_TIMEOUT);
|
||||
(double)priv->latency / 1000,
|
||||
priv->bitrate_per_sec,
|
||||
(double)priv->bitrate_per_sec / 1024 / 1024,
|
||||
main_channel_client_is_low_bandwidth(this) ? " LOW BANDWIDTH" : "");
|
||||
start_connectivity_monitoring(CLIENT_CONNECTIVITY_TIMEOUT);
|
||||
break;
|
||||
default:
|
||||
red_channel_warning(mcc->get_channel(),
|
||||
red_channel_warning(get_channel(),
|
||||
"invalid net test stage, ping id %d test id %d stage %d",
|
||||
ping->id,
|
||||
mcc->priv->net_test_id,
|
||||
mcc->priv->net_test_stage);
|
||||
mcc->priv->net_test_stage = NET_TEST_STAGE_INVALID;
|
||||
priv->net_test_id,
|
||||
priv->net_test_stage);
|
||||
priv->net_test_stage = NET_TEST_STAGE_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -37,6 +37,8 @@ public:
|
||||
RedChannelCapabilities *caps,
|
||||
uint32_t connection_id);
|
||||
|
||||
void handle_pong(SpiceMsgPing *ping, uint32_t size);
|
||||
|
||||
protected:
|
||||
virtual uint8_t *alloc_recv_buf(uint16_t type, uint32_t size) override;
|
||||
virtual void release_recv_buf(uint16_t type, uint32_t size, uint8_t *msg) override;
|
||||
@ -81,8 +83,6 @@ void main_channel_client_migrate_dst_complete(MainChannelClient *mcc);
|
||||
gboolean main_channel_client_migrate_src_complete(MainChannelClient *mcc,
|
||||
gboolean success);
|
||||
|
||||
void main_channel_client_handle_pong(MainChannelClient *mcc, SpiceMsgPing *ping, uint32_t size);
|
||||
|
||||
/*
|
||||
* return TRUE if network test had been completed successfully.
|
||||
* If FALSE, bitrate_per_sec is set to MAX_UINT64 and the roundtrip is set to 0
|
||||
|
||||
@ -191,7 +191,7 @@ bool MainChannelClient::handle_message(uint16_t type, uint32_t size, void *messa
|
||||
reds_on_main_mouse_mode_request(reds, message, size);
|
||||
break;
|
||||
case SPICE_MSGC_PONG:
|
||||
main_channel_client_handle_pong(this, (SpiceMsgPing *)message, size);
|
||||
handle_pong((SpiceMsgPing *)message, size);
|
||||
break;
|
||||
default:
|
||||
return RedChannelClient::handle_message(type, size, message);
|
||||
|
||||
@ -54,8 +54,6 @@ public:
|
||||
* thread. It will not touch the rings, just shutdown the socket.
|
||||
* It should be followed by some way to guarantee a disconnection. */
|
||||
void shutdown();
|
||||
/* handles general channel msgs from the client */
|
||||
virtual bool handle_message(uint16_t type, uint32_t size, void *message);
|
||||
/* when preparing send_data: should call init and then use marshaller */
|
||||
void init_send_data(uint16_t msg_type);
|
||||
|
||||
@ -156,6 +154,9 @@ protected:
|
||||
bool test_remote_common_cap(uint32_t cap) const;
|
||||
void init_outgoing_messages_window();
|
||||
|
||||
/* handles general channel msgs from the client */
|
||||
virtual bool handle_message(uint16_t type, uint32_t size, void *message);
|
||||
|
||||
/* configure socket connected to the client */
|
||||
virtual bool config_socket() { return true; }
|
||||
virtual uint8_t *alloc_recv_buf(uint16_t type, uint32_t size)=0;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user