[Spice-devel] [PATCH spice-gtk] session: correctly track main channel

Hans de Goede hdegoede at redhat.com
Tue May 22 05:09:11 PDT 2012


Looks good, ack.


On 05/22/2012 02:03 PM, Marc-André Lureau wrote:
> The main channel can change when we are reconnecting to the server,
> for example, when querying the password to the user. From there,
> the old main channel is destroyed, but we don't track properly the
> new main channel.
>
> This fix migration crashing later on, because of missing main channel:
> https://bugzilla.redhat.com/show_bug.cgi?id=823874
> ---
>   gtk/spice-session.c |   32 ++++++++++++++++++--------------
>   1 file changed, 18 insertions(+), 14 deletions(-)
>
> diff --git a/gtk/spice-session.c b/gtk/spice-session.c
> index 17b1fe8..fface67 100644
> --- a/gtk/spice-session.c
> +++ b/gtk/spice-session.c
> @@ -1613,6 +1613,9 @@ void spice_session_channel_new(SpiceSession *session, SpiceChannel *channel)
>                        NULL);
>           if (s->color_depth != 0)
>               g_object_set(channel, "color-depth", s->color_depth, NULL);
> +
> +        SPICE_DEBUG("new main channel, switching");
> +        s->cmain = channel;
>       }
>
>       g_signal_emit(session, signals[SPICE_SESSION_CHANNEL_NEW], 0, channel);
> @@ -1623,7 +1626,7 @@ void spice_session_channel_destroy(SpiceSession *session, SpiceChannel *channel)
>   {
>       SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
>       struct channel *item = NULL;
> -    RingItem *ring, *next;
> +    RingItem *ring;
>
>       g_return_if_fail(s != NULL);
>       g_return_if_fail(channel != NULL);
> @@ -1632,22 +1635,23 @@ void spice_session_channel_destroy(SpiceSession *session, SpiceChannel *channel)
>           s->migration_left = g_list_remove(s->migration_left, channel);
>
>       for (ring = ring_get_head(&s->channels); ring != NULL;
> -         ring = next) {
> -        next = ring_next(&s->channels, ring);
> +         ring = ring_next(&s->channels, ring)) {
>           item = SPICE_CONTAINEROF(ring, struct channel, link);
> -        if (item->channel == s->cmain) {
> -            SPICE_DEBUG("the session lost the main channel");
> -            s->cmain = NULL;
> -        }
> -        if (item->channel == channel) {
> -            ring_remove(&item->link);
> -            free(item);
> -            g_signal_emit(session, signals[SPICE_SESSION_CHANNEL_DESTROY], 0, channel);
> -            return;
> -        }
> +        if (item->channel == channel)
> +            break;
> +    }
> +
> +    g_return_if_fail(ring != NULL);
> +
> +    if (channel == s->cmain) {
> +        SPICE_DEBUG("the session lost the main channel");
> +        s->cmain = NULL;
>       }
>
> -    g_warn_if_reached();
> +    ring_remove(&item->link);
> +    free(item);
> +
> +    g_signal_emit(session, signals[SPICE_SESSION_CHANNEL_DESTROY], 0, channel);
>   }
>
>   G_GNUC_INTERNAL


More information about the Spice-devel mailing list