Call red_client_add_channel at the end of initialisation. This respect the previous order. After returning from a successful red_client_add_channel another thread could call some function in this RedChannelClient so make sure is fully initalized. Not doing so for instance could cause a disconnection to a freed RedChannelClient to be scheduled. Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx> --- server/dummy-channel-client.c | 6 ++---- server/red-channel-client.c | 6 +++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/server/dummy-channel-client.c b/server/dummy-channel-client.c index a39941c..c602412 100644 --- a/server/dummy-channel-client.c +++ b/server/dummy-channel-client.c @@ -44,13 +44,11 @@ static gboolean dummy_channel_client_initable_init(GInitable *initable, RedClient *client = red_channel_client_get_client(rcc); RedChannel *channel = red_channel_client_get_channel(rcc); + red_channel_add_client(channel, rcc); if (!red_client_add_channel(client, rcc, &local_error)) { - goto cleanup; + red_channel_remove_client(channel, rcc); } - red_channel_add_client(channel, rcc); - -cleanup: if (local_error) { g_warning("Failed to create channel client: %s", local_error->message); g_propagate_error(error, local_error); diff --git a/server/red-channel-client.c b/server/red-channel-client.c index 5a462dc..bfa44b4 100644 --- a/server/red-channel-client.c +++ b/server/red-channel-client.c @@ -869,9 +869,6 @@ static gboolean red_channel_client_initable_init(GInitable *initable, GError *local_error = NULL; SpiceCoreInterfaceInternal *core; RedChannelClient *self = RED_CHANNEL_CLIENT(initable); - if (!red_client_add_channel(self->priv->client, self, &local_error)) { - goto cleanup; - } if (!red_channel_config_socket(self->priv->channel, self)) { g_set_error_literal(&local_error, @@ -902,6 +899,9 @@ static gboolean red_channel_client_initable_init(GInitable *initable, } red_channel_add_client(self->priv->channel, self); + if (!red_client_add_channel(self->priv->client, self, &local_error)) { + red_channel_remove_client(self->priv->channel, self); + } cleanup: if (local_error) { -- 2.7.4 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel