Re: [spice-gtk v1 03/10] test-file-transfer: Don't leak SpiceFileTransferTask

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

 



On Sat, Jul 30, 2016 at 12:26:24AM +0200, Victor Toso wrote:
> The xfer-task reference given by hash table belongs to the caller so

"stored in the hash table returned by
spice_file_transfer_task_create_tasks"

> we need to release it. Releasing on "finish" callback the same way
> channel-main does but is possible to do on teardown function too.

"This commit releases it in the "finish" callback ... but it is possible
to do it in the teardown function too"

Not directly related to this commit, but are there places in the code
that rely on removing an item from the hash table and expecting to own
a ref on that item? I could not find such a place. In other words, I
don't understand why the g_object_unref() is not passed as a parameter
to g_hash_table_new_full().

Reviewed-by: Christophe Fergeau <cfergeau@xxxxxxxxxx>

Christophe

> ---
>  tests/file-transfer.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/tests/file-transfer.c b/tests/file-transfer.c
> index a27b9cf..bf959ac 100644
> --- a/tests/file-transfer.c
> +++ b/tests/file-transfer.c
> @@ -78,6 +78,12 @@ transfer_xfer_task_on_finished(SpiceFileTransferTask *xfer_task,
>  {
>      Fixture *f = user_data;
>  
> +    if (xfer_task != NULL) {
> +        guint32 task_id = spice_file_transfer_task_get_id(xfer_task);
> +        g_hash_table_remove(f->xfer_tasks, GUINT_TO_POINTER(task_id));
> +        g_object_unref(xfer_task);
> +    }
> +
>      f->num_files_done++;
>      if (f->num_files == f->num_files_done)
>          g_main_loop_quit(f->loop);
> -- 
> 2.7.4
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/spice-devel

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://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]