[Spice-devel] [spice-gtk 1/3] wocky: Simplify wocky_http_proxy_connect_finish()
Victor Toso
lists at victortoso.com
Thu Aug 4 13:13:38 UTC 2016
Hi,
On Wed, Aug 03, 2016 at 09:49:51AM +0200, Christophe Fergeau wrote:
> 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);
You need to move the g_object_unref(data->task) to be before
free_connect_data() (or put the next patch before this one?)
> }
>
> @@ -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);
Yes, data was leaking and GIOStream had an extra ref... Now we just pass
along the GIOStream. Looks okay.
Reviewed-by: Victor Toso <victortoso at redhat.com>
> }
>
> static gboolean
> --
> 2.7.4
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
More information about the Spice-devel
mailing list