diff options
author | Christophe Fergeau <cfergeau@redhat.com> | 2015-02-23 18:54:58 +0100 |
---|---|---|
committer | Frediano Ziglio <fziglio@redhat.com> | 2016-03-09 17:33:53 +0000 |
commit | 91bab2ff1c5a0d06af22a6f1c5300903f662c5e5 (patch) | |
tree | 0f29fdab059091c9c850da7099db787b4698f050 /server/reds.c | |
parent | 30f718aae20170d851ddf9f8626b2ed37eb5d862 (diff) |
Replace RedsPrivate::mig_wait_disconnect_clients with a GList
The code was introducing an intermediate RedsMigWaitDisconnectClient type to
hold linked list elements, resulting in a memory handling behaviour very
similar to a GList. Using GList directly makes the code shorter and more
readable.
Acked-by: Frediano Ziglio <fziglio@redhat.com>
Diffstat (limited to 'server/reds.c')
-rw-r--r-- | server/reds.c | 35 |
1 files changed, 7 insertions, 28 deletions
diff --git a/server/reds.c b/server/reds.c index cffa873b..72282a6f 100644 --- a/server/reds.c +++ b/server/reds.c @@ -2834,11 +2834,8 @@ static void reds_mig_fill_wait_disconnect(RedsState *reds) * of clients that got connected to the src after migration completion.*/ RING_FOREACH(client_item, &reds->clients) { RedClient *client = SPICE_CONTAINEROF(client_item, RedClient, link); - RedsMigWaitDisconnectClient *wait_client; - wait_client = spice_new0(RedsMigWaitDisconnectClient, 1); - wait_client->client = client; - ring_add(&reds->mig_wait_disconnect_clients, &wait_client->link); + reds->mig_wait_disconnect_clients = g_list_append(reds->mig_wait_disconnect_clients, client); } reds->mig_wait_disconnect = TRUE; reds->core->timer_start(reds->mig_timer, MIGRATE_TIMEOUT); @@ -2846,36 +2843,18 @@ static void reds_mig_fill_wait_disconnect(RedsState *reds) static void reds_mig_cleanup_wait_disconnect(RedsState *reds) { - RingItem *wait_client_item; - - while ((wait_client_item = ring_get_tail(&reds->mig_wait_disconnect_clients))) { - RedsMigWaitDisconnectClient *wait_client; - - wait_client = SPICE_CONTAINEROF(wait_client_item, RedsMigWaitDisconnectClient, link); - ring_remove(wait_client_item); - free(wait_client); - } + g_list_free(reds->mig_wait_disconnect_clients); reds->mig_wait_disconnect = FALSE; } static void reds_mig_remove_wait_disconnect_client(RedsState *reds, RedClient *client) { - RingItem *wait_client_item; - - RING_FOREACH(wait_client_item, &reds->mig_wait_disconnect_clients) { - RedsMigWaitDisconnectClient *wait_client; + g_warn_if_fail(g_list_find(reds->mig_wait_disconnect_clients, client) != NULL); - wait_client = SPICE_CONTAINEROF(wait_client_item, RedsMigWaitDisconnectClient, link); - if (wait_client->client == client) { - ring_remove(wait_client_item); - free(wait_client); - if (ring_is_empty(&reds->mig_wait_disconnect_clients)) { - reds_mig_cleanup(reds); - } - return; - } + reds->mig_wait_disconnect_clients = g_list_remove(reds->mig_wait_disconnect_clients, client); + if (reds->mig_wait_disconnect_clients == NULL) { + reds_mig_cleanup(reds); } - spice_warning("client not found %p", client); } static void reds_migrate_channels_seamless(RedsState *reds) @@ -3337,7 +3316,7 @@ static int do_spice_init(RedsState *reds, SpiceCoreInterface *core_interface) ring_init(&reds->channels); ring_init(&reds->mig_target_clients); reds->char_devices = NULL; - ring_init(&reds->mig_wait_disconnect_clients); + reds->mig_wait_disconnect_clients = NULL; reds->vm_running = TRUE; /* for backward compatibility */ if (!(reds->mig_timer = reds->core->timer_add(reds->core, migrate_timeout, reds))) { |