[Spice-devel] [spice-gtk 1/3] wocky: Simplify wocky_http_proxy_connect_finish()

Christophe Fergeau cfergeau at redhat.com
Wed Aug 3 07:49:51 UTC 2016


Rather than returning the whole ConnectAsyncData struct with
g_task_return_pointer(), we can return only the GIOStream object as this
is what we are interested in.
This has the side-effect of fixing a ConnectAsyncData leak as after
calling g_task_propagate_pointer() the old code had ownership of the
ConnectAsyncData instance but was never freeing it.
---
 src/wocky-http-proxy.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/wocky-http-proxy.c b/src/wocky-http-proxy.c
index f62f1fb..d1519b8 100644
--- a/src/wocky-http-proxy.c
+++ b/src/wocky-http-proxy.c
@@ -454,7 +454,9 @@ reply_read_cb (GObject *source,
       return;
     }
 
-  g_task_return_pointer (data->task, data, (GDestroyNotify) free_connect_data);
+  g_task_return_pointer (data->task, data->io_stream, (GDestroyNotify) g_object_unref);
+  data->io_stream = NULL;
+  free_connect_data (data);
   g_object_unref (data->task);
 }
 
@@ -464,9 +466,8 @@ wocky_http_proxy_connect_finish (GProxy *proxy,
     GError **error)
 {
   GTask *task = G_TASK (result);
-  ConnectAsyncData *data = g_task_propagate_pointer (task, error);
 
-  return data ? g_object_ref (data->io_stream) : NULL;
+  return g_task_propagate_pointer (task, error);
 }
 
 static gboolean
-- 
2.7.4



More information about the Spice-devel mailing list