[Spice-devel] [spice-gtk v1 08/10] file-transfer: increase reference for channel-main

Victor Toso lists at victortoso.com
Mon Aug 1 12:51:52 UTC 2016


Hi,

On Mon, Aug 01, 2016 at 12:46:43PM +0200, Christophe Fergeau wrote:
> On Sat, Jul 30, 2016 at 12:26:29AM +0200, Victor Toso wrote:
> > channel-main uses the SpiceFileTransferTask reference given in the
> > hash table provided by spice_file_transfer_task_create_tasks(). That
> > means SpiceFileTransferTask is not holding a reference for itself but
> > it relies on it due the async calls it provides.
> > 
> > This patch increases the reference of each SpiceFileTransferTask for
> > the hash table which will be unref'ed by channel-main in
> > file_transfer_operation_task_finished(); the original reference is
> > kept to SpiceFileTransferTask to be freed after the finish signal is
> > emitted on spice_file_transfer_task_close_stream_cb().
> > 
> > This patch fixes some critical warnings as we have two g_object_unref
> > but only one reference.
> > ---
> >  src/spice-file-transfer-task.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/src/spice-file-transfer-task.c b/src/spice-file-transfer-task.c
> > index ca1b51d..8ebd256 100644
> > --- a/src/spice-file-transfer-task.c
> > +++ b/src/spice-file-transfer-task.c
> > @@ -304,6 +304,7 @@ void spice_file_transfer_task_completed(SpiceFileTransferTask *self,
> >      self->pending = TRUE;
> >  signal:
> >      g_signal_emit(self, task_signals[SIGNAL_FINISHED], 0, self->error);
> > +    /* SpiceFileTransferTask unref is done after inpust stream is closed */
>
> typo: s/inpust/input/

Fixed!

>
> >  }
> >  
> >  G_GNUC_INTERNAL
> > @@ -374,7 +375,7 @@ GHashTable *spice_file_transfer_task_create_tasks(GFile **files,
> >          xfer_task->flags = flags;
> >  
> >          task_id = spice_file_transfer_task_get_id(xfer_task);
> > -        g_hash_table_insert(xfer_ht, GUINT_TO_POINTER(task_id), xfer_task);
> > +        g_hash_table_insert(xfer_ht, GUINT_TO_POINTER(task_id), g_object_ref(xfer_task));
>
> I'd change the hash table creation to g_hash_table_new_full() so that
> the unref() is done automatically on destroy.

Yes, make sense. I'll fix it, thanks!

>
> Christophe



> _______________________________________________
> 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