mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2025-12-27 07:29:32 +00:00
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:
parent
c91fbc155b
commit
3a5007d18f
@ -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);
|
||||
}
|
||||
|
||||
@ -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));
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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));
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user