summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2012-12-23 20:56:09 +0100
committerMarc-André Lureau <marcandre.lureau@redhat.com>2012-12-27 00:05:34 +0100
commit5ed7f06e7c7a9fa9c6b0411debd43793335068ec (patch)
treeec52390aacccd06fc1d4c76fac232b5e54f90004 /gtk
parent845c569f2539c61835e3e71994a3830edc555b16 (diff)
Clean-up idle handler when leaving the open_host_idle()
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.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/spice-session.c10
1 files 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);
}