[Spice-devel] [PATCH spice-server 2/2] reds: Check we don't register a channel twice in reds_register_channel

Christophe Fergeau cfergeau at redhat.com
Tue Mar 19 13:48:48 UTC 2019


On Tue, Mar 19, 2019 at 01:01:55PM +0000, Frediano Ziglio wrote:
> To avoid possibly regression check it only if extra checks are

"To avoid possible/potential regressions, check it .."

> enabled.
> This allows to check previous "Move channel registration to constructed
> vfunc" commit.
> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> Acked-by: Snir Sheriber <ssheribe at redhat.com>
> ---
>  server/reds.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/server/reds.c b/server/reds.c
> index bc043764..f84ab1b8 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -380,6 +380,11 @@ void stat_remove_counter(SpiceServer *reds, RedStatCounter *counter)
>  void reds_register_channel(RedsState *reds, RedChannel *channel)
>  {
>      spice_assert(reds);
> +    if (spice_extra_checks) {
> +        uint32_t this_type, this_id;
> +        g_object_get(channel, "channel-type", &this_type, "id", &this_id, NULL);
> +        spice_assert(reds_find_channel(reds, this_type, this_id) == NULL);
> +    }

Maybe something like this:

uint32_t this_type, this_id;
g_object_get(channel, "channel-type", &this_type, "id", &this_id, NULL);
if (spice_extra_checks) {
    g_warn_if_fail(reds_find_channel(reds, this_type, this_id) == NULL);
} else
    g_assert(reds_find_channel(reds, this_type, this_id) == NULL);
}

so that we can catch these misuses?

Christophe


>      reds->channels = g_list_prepend(reds->channels, channel);
>      // create new channel in the client if possible
>      main_channel_registered_new_channel(reds->main_channel, channel);
> -- 
> 2.20.1
> 
> _______________________________________________
> 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: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20190319/db9ae00e/attachment.sig>


More information about the Spice-devel mailing list