Re: [spice-gtk v1 2/3] main: migration: check return value to count channels

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

 



Hi,

On Thu, Sep 05, 2019 at 03:51:40AM -0400, Frediano Ziglio wrote:
> > 
> > From: Victor Toso <me@xxxxxxxxxxxxxx>
> > 
> > Although spice_channel_connect() works in idle, if it returns false
> > it'll not emit any signal further and we would be counting a
> > 'connected' channel that wouldn't be emitting anything.
> > 
> > As other callbacks take this in consideration, we should only
> > increment the counter if we reached spice-channel::connect_delayed()
> > callback.
> > 
> > Signed-off-by: Victor Toso <victortoso@xxxxxxxxxx>
> > ---
> >  src/channel-main.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/src/channel-main.c b/src/channel-main.c
> > index a1e5498..3d1b1b5 100644
> > --- a/src/channel-main.c
> > +++ b/src/channel-main.c
> > @@ -2174,8 +2174,9 @@ migrate_channel_connect(spice_migrate *mig, int type,
> > int id)
> >      SPICE_DEBUG("migrate_channel_connect %d:%d", type, id);
> >  
> >      SpiceChannel *newc = spice_channel_new(mig->session, type, id);
> > -    spice_channel_connect(newc);
> > -    mig->nchannels++;
> > +    if (newc != NULL && spice_channel_connect(newc)) {
> > +        mig->nchannels++;
> > +    }
> >  }
> >  
> >  /* coroutine context */
> 
> Acked-by: Frediano Ziglio <fziglio@xxxxxxxxxx>

Thanks,

> 
> It makes sense but if spice_channel_connect for any reason fails the channel
> will go to unconnected state and we will "forget" the pointer so basically
> looks like a leak.

In such case, in the migration part, we should catch
SpiceChannel::channel-event with error, which would abort
migration and free the related resources..

The leak you mention could also be a hang, that is, waiting
nchannels reach to 0

> At least I would expect that if I attempt to disconnect it the
> object is freed.

Note that this is more of code inspection kinda change, makes no
sense to nchannels++ if spice_channel_connect() failed early for
whatever reason. Didn't hit an issue with this code path.

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 Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]