Re: [PATCH spice-server 4/4] red-client: Make sure MainChannelClient is freed as last

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

 



On Wed, Aug 30, 2017 at 01:51:28PM +0100, Frediano Ziglio wrote:
> MainChannelClient is used by other clients to store some data
> so should not disappear if other clients are still present.
> Keep a owning reference to it and release after RedClient is
> released.
> 
> Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> ---
>  server/red-client.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/server/red-client.c b/server/red-client.c
> index 36577dab..7e1394e5 100644
> --- a/server/red-client.c
> +++ b/server/red-client.c
> @@ -108,6 +108,10 @@ red_client_finalize (GObject *object)
>  {
>      RedClient *self = RED_CLIENT(object);
>  
> +    if (self->mcc) {
> +        g_object_unref(self->mcc);
> +        self->mcc = NULL;
> +    }

This could be g_clear_object(&self->mcc);

>      spice_debug("release client=%p", self);
>      pthread_mutex_destroy(&self->lock);
>  
> @@ -314,7 +318,8 @@ MainChannelClient *red_client_get_main(RedClient *client)
>  
>  void red_client_set_main(RedClient *client, MainChannelClient *mcc)
>  {
> -    client->mcc = mcc;
> +    spice_assert(client->mcc == NULL);

Why not
if (client->mcc != NULL) {
    g_warn_if_reached();
    g_object_unref(client->mcc);
}
client->mcc = g_object_ref(mcc);
?

Acked-by: Christophe Fergeau <cfergeau@xxxxxxxxxx>

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