From 201a8c2e36e250f49d5c729b11563730dfa4c484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 16 Dec 2014 18:04:53 +0100 Subject: [PATCH spice-gtk 5/6] channel: throw auth error when coroutine ends It is common that clients attempt to reconnect during the SPICE_CHANNEL_ERROR_AUTH callback. However, the channel must exit the coroutine first before reconnection can happen. --- gtk/spice-channel.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c index 4081e0b..c00bb42 100644 --- a/gtk/spice-channel.c +++ b/gtk/spice-channel.c @@ -1069,8 +1069,6 @@ static void spice_channel_failed_authentication(SpiceChannel *channel) c->state = SPICE_CHANNEL_STATE_FAILED_AUTHENTICATION; - g_coroutine_signal_emit(channel, signals[SPICE_CHANNEL_EVENT], 0, SPICE_CHANNEL_ERROR_AUTH); - c->has_error = TRUE; /* force disconnect */ } @@ -2182,6 +2180,9 @@ static gboolean spice_channel_delayed_unref(gpointer data) g_return_val_if_fail(c->coroutine.coroutine.exited == TRUE, FALSE); + if (c->state == SPICE_CHANNEL_STATE_FAILED_AUTHENTICATION) + g_coroutine_signal_emit(channel, signals[SPICE_CHANNEL_EVENT], 0, SPICE_CHANNEL_ERROR_AUTH); + g_object_unref(G_OBJECT(data)); return FALSE; @@ -2458,6 +2459,7 @@ static gboolean connect_delayed(gpointer data) return FALSE; } +/* any context */ static gboolean channel_connect(SpiceChannel *channel) { SpiceChannelPrivate *c = channel->priv; @@ -2639,7 +2641,6 @@ static void channel_disconnect(SpiceChannel *channel) if (c->state == SPICE_CHANNEL_STATE_READY) g_coroutine_signal_emit(channel, signals[SPICE_CHANNEL_EVENT], 0, SPICE_CHANNEL_CLOSED); - c->state = SPICE_CHANNEL_STATE_UNCONNECTED; spice_channel_reset(channel, FALSE); g_return_if_fail(SPICE_IS_CHANNEL(channel)); -- 2.1.0