summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2012-12-20 16:55:29 +0100
committerMarc-André Lureau <marcandre.lureau@redhat.com>2012-12-21 16:24:40 +0100
commit95321c4a6241baad2d4fc89d34af76d5e9a6a982 (patch)
treebe2dba7d4119b7037b93922da048571048c317c1
parent753a96837c4a02a4017c3eb1f1e4cfe260aa3c28 (diff)
session: improve open_host() clean-up
Make sure the GSocketClient is unref when leaving the function, and not left around in some unfinished async state.
-rw-r--r--gtk/spice-session.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index 0d858fb..b18d67b 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -1585,6 +1585,7 @@ struct spice_open_host {
GCancellable *cancellable;
GError *error;
GSocket *socket;
+ GSocketClient *client;
};
static void socket_client_connect_ready(GObject *source_object, GAsyncResult *result,
@@ -1604,19 +1605,16 @@ static void socket_client_connect_ready(GObject *source_object, GAsyncResult *re
end:
g_clear_object(&connection);
- g_clear_object(&client);
-
coroutine_yieldto(open_host->from, NULL);
}
/* main context */
static void open_host_connectable_connect(spice_open_host *open_host, GSocketConnectable *connectable)
{
- GSocketClient *client;
-
SPICE_DEBUG("connecting %p...", open_host);
- client = g_socket_client_new();
- g_socket_client_connect_async(client, connectable, open_host->cancellable,
+
+ g_socket_client_connect_async(open_host->client, connectable,
+ open_host->cancellable,
socket_client_connect_ready, open_host);
}
@@ -1709,10 +1707,12 @@ GSocket* spice_session_channel_open_host(SpiceSession *session, SpiceChannel *ch
if ((use_tls && !s->tls_port) || (!use_tls && !s->port))
return NULL;
+ // FIXME: make open_host() cancellable
open_host.from = coroutine_self();
open_host.session = session;
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);
/* switch to main loop and wait for connection */
@@ -1729,6 +1729,7 @@ GSocket* spice_session_channel_open_host(SpiceSession *session, SpiceChannel *ch
g_socket_set_keepalive(open_host.socket, TRUE);
}
+ g_clear_object(&open_host.client);
g_clear_object(&open_host.proxy);
return open_host.socket;
}