red-client: Automatically set MainChannelClient

This make sure that the RedClient has always an attached
MainChannelClient.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
Frediano Ziglio 2017-08-25 10:02:28 +01:00
parent 59be4f19c4
commit 5f02dff835
5 changed files with 5 additions and 11 deletions

View File

@ -295,6 +295,11 @@ gboolean red_client_add_channel(RedClient *client, RedChannelClient *rcc, GError
goto cleanup;
}
// first must be the main one
if (!client->mcc) {
client->mcc = g_object_ref(rcc);
spice_assert(MAIN_CHANNEL_CLIENT(rcc) != NULL);
}
client->channels = g_list_prepend(client->channels, rcc);
if (client->during_target_migrate && client->seamless_migrate) {
if (red_channel_client_set_migration_seamless(rcc)) {
@ -312,12 +317,6 @@ MainChannelClient *red_client_get_main(RedClient *client)
return client->mcc;
}
void red_client_set_main(RedClient *client, MainChannelClient *mcc)
{
spice_assert(client->mcc == NULL);
client->mcc = g_object_ref(mcc);
}
void red_client_semi_seamless_migrate_complete(RedClient *client)
{
RedChannelClient *rcc;

View File

@ -39,8 +39,6 @@ gboolean red_client_add_channel(RedClient *client, RedChannelClient *rcc, GError
void red_client_remove_channel(RedChannelClient *rcc);
MainChannelClient *red_client_get_main(RedClient *client);
// main should be set once before all the other channels are created
void red_client_set_main(RedClient *client, MainChannelClient *mcc);
/* called when the migration handshake results in seamless migration (dst side).
* By default we assume semi-seamless */

View File

@ -1902,7 +1902,6 @@ static void reds_handle_main_link(RedsState *reds, RedLinkInfo *link)
red_channel_capabilities_reset(&caps);
spice_debug("NEW Client %p mcc %p connect-id %d", client, mcc, connection_id);
g_free(link_mess);
red_client_set_main(client, mcc);
if (reds->vdagent) {
if (mig_target) {

View File

@ -289,7 +289,6 @@ static void channel_loop(void)
mcc = main_channel_link(main_channel, client, create_dummy_stream(server, NULL),
0, FALSE, &caps);
g_assert_nonnull(mcc);
red_client_set_main(client, mcc);
// inject a trace into the core interface to count the events
SpiceCoreInterfaceInternal *server_core = reds_get_core_interface(server);

View File

@ -337,7 +337,6 @@ static void test_smartcard(TestFixture *fixture, gconstpointer user_data)
mcc = main_channel_link(main_channel, client, create_dummy_stream(server, NULL),
0, FALSE, &caps);
g_assert_nonnull(mcc);
red_client_set_main(client, mcc);
// create our testing RedChannelClient
red_channel_connect(channel, client, create_dummy_stream(server, &client_socket),