[Spice-devel] [PATCH v4 08/14] sound: Implement on_disconnect RedChannel callback

Frediano Ziglio fziglio at redhat.com
Thu Dec 1 12:53:03 UTC 2016


> 
> On Wed, Nov 30, 2016 at 12:34:52PM +0000, Frediano Ziglio wrote:
> > Avoid having dandling pointer to a client.
> 
> 'dangling'
> 

I though I merged this patch in "sound: Convert SndChannelClient to GObject".
I did some mistake probably, but will be merged to that patch anyway.

> > 
> > Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> > ---
> >  server/sound.c |  9 +++++++++
> >  1 file changed, 9 insertions(+)
> > 
> > diff --git a/server/sound.c b/server/sound.c
> > index a5b960b..00eab67 100644
> > --- a/server/sound.c
> > +++ b/server/sound.c
> > @@ -773,6 +773,14 @@ static int snd_channel_config_socket(RedChannelClient
> > *rcc)
> >      return TRUE;
> >  }
> >  
> > +static void snd_channel_on_disconnect(RedChannelClient *rcc)
> > +{
> > +    SndChannel *channel =
> > SND_CHANNEL(red_channel_client_get_channel(rcc));
> > +    if (channel->connection && rcc ==
> > RED_CHANNEL_CLIENT(channel->connection)) {
> 
> Is it expected that channel->connection will sometimes not be equal to rcc
> here? Or
> should it issue some kind of runtime warning if this happens?
> 

I think is quite paranoid check. There is currently only one client
so channel->connection should be the same.
Maybe could happen that a second client connect basically kicking out
the old one so possibly this could be the onle reason having
channel->connection && rcc != channel->connection.
I was thinking to remove the connection field and use client list from RedChannel
instead.
I was thinking also to add support for multiple clients to the code as
an improvement and as a demonstration that current code is better
than what it used to be but I don't know what to do for the recording!
Mix all recordings? Keep a main client channel and discard the others?

> > +        channel->connection = NULL;
> 
> Christophe
> 

Frediano


More information about the Spice-devel mailing list