[Spice-devel] [PATCHv2 spice-gtk 5/5] channel: throw auth error when coroutine ends

Marc-André Lureau marcandre.lureau at redhat.com
Tue Dec 16 09:11:08 PST 2014


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



More information about the Spice-devel mailing list