[Spice-devel] [PATCH spice-gtk v2 06/19] migration: set connecting state before fd request
Marc-André Lureau
marcandre.lureau at gmail.com
Fri Nov 14 05:42:32 PST 2014
Following first review thread, comment is updated with
During migration, the main channel coroutine initiating the process is
waiting
for connection completion of all channels. migrate_channel_event_cb() yields
back to the main channel coroutine once all channels have completed
connection,
or it will abort migration for unexpected channel events, such as
SPICE_CHANNEL_CLOSED
...
On Fri, Nov 14, 2014 at 12:32 AM, Marc-André Lureau <
marcandre.lureau at redhat.com> wrote:
> During migration, the main channel initiating the process is waiting on
> connection completion of all channels in migrate_channel_event_cb() or
> it will abort migration for unexpected channel events, such as
> SPICE_CHANNEL_CLOSED.
>
> If the migration is cancelled before connection completes, but the
> channels state are still in the SPICE_CHANNEL_STATE_UNCONNECTED state,
> no events will be emitted in channel_disconnect(), and the source
> session main channel will remain frozen waiting for migration completion
> or failure.
>
> Currently, for client-fd channels, the channel state remains UNCONNECTED
> until the fd is provided. But if cancellation occurs, no channel events
> are emitted and the source session is stuck.
>
> Before requesting the fd, set the channel state to connecting, so it
> will emit an error if disconnect happens, and it will finish cancelling
> the migration in source session main channel.
> ---
> gtk/spice-channel.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
> index f59127e..3966560 100644
> --- a/gtk/spice-channel.c
> +++ b/gtk/spice-channel.c
> @@ -2461,10 +2461,8 @@ static gboolean channel_connect(SpiceChannel
> *channel)
> g_warning("%s: channel setup incomplete", __FUNCTION__);
> return false;
> }
> - if (c->state != SPICE_CHANNEL_STATE_UNCONNECTED) {
> - g_warning("Invalid channel_connect state: %d", c->state);
> - return true;
> - }
> +
> + c->state = SPICE_CHANNEL_STATE_CONNECTING;
>
> if (spice_session_get_client_provided_socket(c->session)) {
> if (c->fd == -1) {
> @@ -2476,7 +2474,7 @@ static gboolean channel_connect(SpiceChannel
> *channel)
> return true;
> }
> }
> - c->state = SPICE_CHANNEL_STATE_CONNECTING;
> +
> c->xmit_queue_blocked = FALSE;
>
> g_return_val_if_fail(c->sock == NULL, FALSE);
> @@ -2532,6 +2530,11 @@ gboolean spice_channel_open_fd(SpiceChannel
> *channel, int fd)
> g_return_val_if_fail(fd >= -1, FALSE);
>
> c = channel->priv;
> + if (c->state > SPICE_CHANNEL_STATE_CONNECTING) {
> + g_warning("Invalid channel_connect state: %d", c->state);
> + return true;
> + }
> +
> c->fd = fd;
>
> return channel_connect(channel);
> --
> 1.9.3
>
>
--
Marc-André Lureau
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20141114/8b3a847a/attachment.html>
More information about the Spice-devel
mailing list