red-channel: unregister channel in red_channel_destroy

Mostly of red_channel_destroy calls were preceded by
a call to unregister the channel.
The only exception was the main channel as this channel is
always present and its initialisation is a bit different.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
Frediano Ziglio 2017-08-18 12:12:19 +01:00
parent c91fbc155b
commit 3a5007d18f
5 changed files with 5 additions and 21 deletions

View File

@ -401,6 +401,9 @@ void red_channel_destroy(RedChannel *channel)
return;
}
// prevent future connection
reds_unregister_channel(channel->priv->reds, channel);
g_list_foreach(channel->priv->clients, (GFunc)red_channel_client_destroy, NULL);
g_object_unref(channel);
}

View File

@ -1419,12 +1419,6 @@ static void red_worker_close_channel(RedChannel *channel)
*/
void red_worker_free(RedWorker *worker)
{
RedsState *reds = red_qxl_get_server(worker->qxl->st);
/* prevent any possible future attempt to connect to new clients */
reds_unregister_channel(reds, RED_CHANNEL(worker->cursor_channel));
reds_unregister_channel(reds, RED_CHANNEL(worker->display_channel));
pthread_join(worker->thread, NULL);
red_worker_close_channel(RED_CHANNEL(worker->cursor_channel));

View File

@ -391,11 +391,7 @@ void reds_register_channel(RedsState *reds, RedChannel *channel)
void reds_unregister_channel(RedsState *reds, RedChannel *channel)
{
if (g_list_find(reds->channels, channel)) {
reds->channels = g_list_remove(reds->channels, channel);
} else {
spice_warning("not found");
}
reds->channels = g_list_remove(reds->channels, channel);
}
RedChannel *reds_find_channel(RedsState *reds, uint32_t type, uint32_t id)
@ -3705,7 +3701,6 @@ SPICE_GNUC_VISIBLE void spice_server_destroy(SpiceServer *reds)
g_list_free_full(reds->qxl_instances, (GDestroyNotify)red_qxl_destroy);
if (reds->inputs_channel) {
reds_unregister_channel(reds, RED_CHANNEL(reds->inputs_channel));
red_channel_destroy(RED_CHANNEL(reds->inputs_channel));
}
if (reds->main_channel) {

View File

@ -1428,9 +1428,7 @@ static void snd_detach_common(SndChannel *channel)
if (!channel) {
return;
}
RedsState *reds = red_channel_get_server(RED_CHANNEL(channel));
reds_unregister_channel(reds, RED_CHANNEL(channel));
red_channel_destroy(RED_CHANNEL(channel));
}

View File

@ -892,17 +892,11 @@ red_char_device_spicevmc_dispose(GObject *object)
RedCharDeviceSpiceVmc *self = RED_CHAR_DEVICE_SPICEVMC(object);
if (self->channel) {
RedChannel *channel = RED_CHANNEL(self->channel);
RedsState *reds = red_char_device_get_server(RED_CHAR_DEVICE(self));
// prevent possible recursive calls
self->channel->chardev = NULL;
// prevent future connection
reds_unregister_channel(reds, channel);
// close all current connections and drop the reference
red_channel_destroy(channel);
red_channel_destroy(RED_CHANNEL(self->channel));
self->channel = NULL;
}
G_OBJECT_CLASS(red_char_device_spicevmc_parent_class)->dispose(object);