[Spice-devel] [spice-gtk v1 03/10] test-file-transfer: Don't leak SpiceFileTransferTask
Christophe Fergeau
cfergeau at redhat.com
Mon Aug 1 10:27:17 UTC 2016
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 at redhat.com>
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 at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20160801/24f19248/attachment.sig>
More information about the Spice-devel
mailing list