[Spice-devel] [PATCHv1 spice-gtk 3/3] channel: wait until coroutine ends

Marc-André Lureau marcandre.lureau at redhat.com
Tue Dec 16 06:22:57 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 | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index d0e6df8..f7dbf2c 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 */
 }
 
@@ -2178,6 +2176,11 @@ 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) {
+        c->state = SPICE_CHANNEL_STATE_UNCONNECTED;
+        g_coroutine_signal_emit(channel, signals[SPICE_CHANNEL_EVENT], 0, SPICE_CHANNEL_ERROR_AUTH);
+    }
+
     g_object_unref(G_OBJECT(data));
 
     return FALSE;
@@ -2640,7 +2643,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