red-channel-client: Make start_connectivity_monitoring protected

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
Frediano Ziglio 2020-03-03 10:01:37 +00:00 committed by Frediano Ziglio
parent aecbdd9e5b
commit 2d865a78da
4 changed files with 14 additions and 11 deletions

View File

@ -175,23 +175,23 @@ static RedPipeItem *main_notify_item_new(const char *msg, int num)
return &item->base;
}
void main_channel_client_start_net_test(MainChannelClient *mcc, int test_rate)
void MainChannelClient::start_net_test(int test_rate)
{
if (!mcc || mcc->priv->net_test_id) {
if (priv->net_test_id) {
return;
}
if (!test_rate) {
mcc->start_connectivity_monitoring(CLIENT_CONNECTIVITY_TIMEOUT);
start_connectivity_monitoring(CLIENT_CONNECTIVITY_TIMEOUT);
return;
}
mcc->priv->net_test_id = mcc->priv->ping_id + 1;
mcc->priv->net_test_stage = NET_TEST_STAGE_WARMUP;
priv->net_test_id = priv->ping_id + 1;
priv->net_test_stage = NET_TEST_STAGE_WARMUP;
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);
main_channel_client_push_ping(this, NET_TEST_WARMUP_BYTES);
main_channel_client_push_ping(this, 0);
main_channel_client_push_ping(this, NET_TEST_BYTES);
}
static RedPipeItem *red_ping_item_new(int size)

View File

@ -38,6 +38,7 @@ public:
uint32_t connection_id);
void handle_pong(SpiceMsgPing *ping, uint32_t size);
void start_net_test(int test_rate);
protected:
virtual uint8_t *alloc_recv_buf(uint16_t type, uint32_t size) override;
@ -60,7 +61,6 @@ MainChannelClient *main_channel_client_create(MainChannel *main_chan, RedClient
void main_channel_client_push_agent_tokens(MainChannelClient *mcc, uint32_t num_tokens);
void main_channel_client_push_agent_data(MainChannelClient *mcc, uint8_t* data, size_t len,
spice_marshaller_item_free_func free_data, void *opaque);
void main_channel_client_start_net_test(MainChannelClient *mcc, int test_rate);
// TODO: huge. Consider making a reds_* interface for these functions
// and calling from main.
void main_channel_client_push_init(MainChannelClient *mcc,

View File

@ -79,9 +79,11 @@ public:
/* returns -1 if we don't have an estimation */
int get_roundtrip_ms() const;
protected:
/* Checks periodically if the connection is still alive */
void start_connectivity_monitoring(uint32_t timeout_ms);
public:
void pipe_add_push(RedPipeItem *item);
void pipe_add(RedPipeItem *item);
void pipe_add_after(RedPipeItem *item, RedPipeItem *pos);

View File

@ -1907,8 +1907,9 @@ static void reds_handle_main_link(RedsState *reds, RedLinkInfo *link)
reds_mig_target_client_add(reds, client);
}
if (red_stream_get_family(stream) != AF_UNIX)
main_channel_client_start_net_test(mcc, !mig_target);
if (red_stream_get_family(stream) != AF_UNIX) {
mcc->start_net_test(!mig_target);
}
}
#define RED_MOUSE_STATE_TO_LOCAL(state) \