[PATCH spice-gtk 1/2] Clean-up idle handler when leaving the open_host_idle()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



An explicit yield back to the channel coroutine when the idle function
is still pending will leave it in the background, referencing objects
that may no longer exist. Make sure we remove it when
channel_open_host() is resumed.
---
 gtk/spice-session.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index b18d67b..f1d6250 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -1713,18 +1713,16 @@ GSocket* spice_session_channel_open_host(SpiceSession *session, SpiceChannel *ch
     open_host.channel = channel;
     open_host.port = atoi(use_tls ? s->tls_port : s->port);
     open_host.client = g_socket_client_new();
-    g_idle_add(open_host_idle_cb, &open_host);
 
+    guint id = g_idle_add(open_host_idle_cb, &open_host);
     /* switch to main loop and wait for connection */
     coroutine_yield(NULL);
-    if (open_host.error != NULL) {
-        g_return_val_if_fail(open_host.socket == NULL, NULL);
+    g_source_remove (id);
 
+    if (open_host.error != NULL) {
         g_warning("%s", open_host.error->message);
         g_clear_error(&open_host.error);
-    } else {
-        g_return_val_if_fail(open_host.socket != NULL, NULL);
-
+    } else if (open_host.socket != NULL) {
         g_socket_set_blocking(open_host.socket, FALSE);
         g_socket_set_keepalive(open_host.socket, TRUE);
     }
-- 
1.8.1.rc1.17.g75ed918

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]