[Spice-commits] 9 commits - gtk/spice-channel.c gtk/spice-channel.h gtk/spice-session.c
Marc-André Lureau
elmarco at kemper.freedesktop.org
Wed Feb 18 05:03:07 PST 2015
gtk/spice-channel.c | 47 ++++++++++++++---------------------------------
gtk/spice-channel.h | 2 +-
gtk/spice-session.c | 1 +
3 files changed, 16 insertions(+), 34 deletions(-)
New commits:
commit a1897e41423724fd484a7dcebc99b20e78d2ace9
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Mon Feb 16 17:38:33 2015 +0100
session: reset connection_id on switch-host
The server expects no connection_id during link time, in order to
realize a full reconnection.
The alternative would be to assume that the destination server has the
exact same channels and attempt to recreate and to reconnect them one by
one. However, if the destination is slightly different (say,
configuration or order of channels differs), this will likely fail. It's
best to start with a new session without prior knowledge.
diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index 8de48e5..82ea55f 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -1557,6 +1557,7 @@ void spice_session_switching_disconnect(SpiceSession *self)
g_warn_if_fail(!ring_is_empty(&s->channels)); /* ring_get_length() == 1 */
cache_clear_all(self);
+ s->connection_id = 0;
}
#define SWAP_STR(x, y) G_STMT_START { \
commit 71b4b286889e6143a28c07ab393d541dad1016ec
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Mon Feb 16 13:14:39 2015 +0100
channel: remove unused ChannelClass::channel_disconnect()
This virtual method turns out to be unnecessary anymore, and
was never override. channel_reset() is enough.
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index 0d5e5e7..95eb615 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -51,7 +51,6 @@
static void spice_channel_handle_msg(SpiceChannel *channel, SpiceMsgIn *msg);
static void spice_channel_write_msg(SpiceChannel *channel, SpiceMsgOut *out);
static void spice_channel_send_link(SpiceChannel *channel);
-static void channel_disconnect(SpiceChannel *channel);
static void channel_reset(SpiceChannel *channel, gboolean migrating);
static void spice_channel_reset_capabilities(SpiceChannel *channel);
static void spice_channel_send_migration_handshake(SpiceChannel *channel);
@@ -270,7 +269,6 @@ static void spice_channel_class_init(SpiceChannelClass *klass)
klass->iterate_write = spice_channel_iterate_write;
klass->iterate_read = spice_channel_iterate_read;
- klass->channel_disconnect = channel_disconnect;
klass->channel_reset = channel_reset;
gobject_class->constructed = spice_channel_constructed;
@@ -2643,23 +2641,6 @@ void spice_channel_reset(SpiceChannel *channel, gboolean migrating)
SPICE_CHANNEL_GET_CLASS(channel)->channel_reset(channel, migrating);
}
-/* system or coroutine context */
-static void channel_disconnect(SpiceChannel *channel)
-{
- SpiceChannelPrivate *c = channel->priv;
-
- g_return_if_fail(c != NULL);
-
- if (c->state == SPICE_CHANNEL_STATE_UNCONNECTED)
- return;
-
- c->has_error = TRUE; /* break the loop */
-
- spice_channel_reset(channel, FALSE);
-
- g_return_if_fail(SPICE_IS_CHANNEL(channel));
-}
-
/**
* spice_channel_disconnect:
* @channel:
diff --git a/gtk/spice-channel.h b/gtk/spice-channel.h
index 8d07383..7f132f6 100644
--- a/gtk/spice-channel.h
+++ b/gtk/spice-channel.h
@@ -86,7 +86,7 @@ struct _SpiceChannelClass
/*< private >*/
/* virtual method, any context */
- void (*channel_disconnect)(SpiceChannel *channel);
+ gpointer deprecated;
void (*channel_reset)(SpiceChannel *channel, gboolean migrating);
void (*channel_reset_capabilities)(SpiceChannel *channel);
commit ed9066c19abe2558914f35d4f54d39bd5910285a
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Mon Feb 16 13:07:57 2015 +0100
channel: set c->has_error to finish coroutine
It's unnecessary to call channel_disconnect() to finish the coroutine
and disconnect. Use c->has_error instead, like the rest of channel error
code.
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index a849dde..0d5e5e7 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -1763,7 +1763,7 @@ static gboolean spice_channel_recv_link_msg(SpiceChannel *channel)
return TRUE;
error:
- SPICE_CHANNEL_GET_CLASS(channel)->channel_disconnect(channel);
+ c->has_error = TRUE;
c->event = SPICE_CHANNEL_ERROR_LINK;
return FALSE;
}
commit fb044fd8067e3e2022d918352c907a1b9b9bbfa0
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Mon Feb 16 13:02:36 2015 +0100
Call channel_reset() directly when finishing coroutine
channel_disconnect() virtual method isn't overloaded by any
channel, and can be replaced by the equivalent channel_reset()
when finishing the coroutine.
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index 2df021d..a849dde 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -2435,7 +2435,7 @@ connected:
cleanup:
CHANNEL_DEBUG(channel, "Coroutine exit %s", c->name);
- SPICE_CHANNEL_GET_CLASS(channel)->channel_disconnect(channel);
+ spice_channel_reset(channel, FALSE);
if (c->state == SPICE_CHANNEL_STATE_RECONNECTING ||
c->state == SPICE_CHANNEL_STATE_SWITCHING) {
commit 3c8987ca8e78502361263e7e180eb37aca405c83
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Mon Feb 16 13:28:03 2015 +0100
channel: reset migration state when calling channel_reset()
channel_reset() is called in channel_disconnect(). We can just move that
state change in channel_reset() in order to get rid of
channel_disconnect().
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index f036105..2df021d 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -2629,6 +2629,10 @@ static void channel_reset(SpiceChannel *channel, gboolean migrating)
spice_channel_set_common_capability(channel, SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION);
spice_channel_set_common_capability(channel, SPICE_COMMON_CAP_MINI_HEADER);
spice_channel_reset_capabilities(channel);
+
+ if (c->state == SPICE_CHANNEL_STATE_SWITCHING)
+ spice_session_set_migration_state(spice_channel_get_session(channel),
+ SPICE_SESSION_MIGRATION_NONE);
}
/* system or coroutine context */
@@ -2654,11 +2658,6 @@ static void channel_disconnect(SpiceChannel *channel)
spice_channel_reset(channel, FALSE);
g_return_if_fail(SPICE_IS_CHANNEL(channel));
-
- if (c->state == SPICE_CHANNEL_STATE_SWITCHING) {
- spice_session_set_migration_state(spice_channel_get_session(channel),
- SPICE_SESSION_MIGRATION_NONE);
- }
}
/**
commit 14445baafc8dbf3745884ee06531c131df47ad58
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Mon Feb 16 12:59:35 2015 +0100
channel: use exisiting reconnection code when switching
Switching for migration reason is similar to a reconnection during
initial connection.
A notable difference is that new code path doesn't schedule a
delayed_unref callback. This is fine since the channel is still running
and delayed_unref is mainly used for signaling disconnections and none
should be emitted when switching.
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index e3c4299..f036105 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -2437,7 +2437,8 @@ cleanup:
SPICE_CHANNEL_GET_CLASS(channel)->channel_disconnect(channel);
- if (c->state == SPICE_CHANNEL_STATE_RECONNECTING) {
+ if (c->state == SPICE_CHANNEL_STATE_RECONNECTING ||
+ c->state == SPICE_CHANNEL_STATE_SWITCHING) {
g_warn_if_fail(c->event == SPICE_CHANNEL_NONE);
channel_connect(channel, c->tls);
g_object_unref(channel);
@@ -2655,7 +2656,6 @@ static void channel_disconnect(SpiceChannel *channel)
g_return_if_fail(SPICE_IS_CHANNEL(channel));
if (c->state == SPICE_CHANNEL_STATE_SWITCHING) {
- channel_connect(channel, c->tls);
spice_session_set_migration_state(spice_channel_get_session(channel),
SPICE_SESSION_MIGRATION_NONE);
}
commit 25683f91b20753a0a2b52370c9ca55e09597aa54
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Mon Feb 16 12:55:34 2015 +0100
channel: reset channel state to unconnected
After coroutine has exited, reset channel state to unconnected,
this allows recycling a channel for reconnection, even in "normal"
disconnect/reconnect cases.
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index 100f272..e3c4299 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -2183,8 +2183,9 @@ static gboolean spice_channel_delayed_unref(gpointer data)
g_return_val_if_fail(c->coroutine.coroutine.exited == TRUE, FALSE);
+ c->state = SPICE_CHANNEL_STATE_UNCONNECTED;
+
if (c->event != SPICE_CHANNEL_NONE) {
- c->state = SPICE_CHANNEL_STATE_UNCONNECTED;
g_coroutine_signal_emit(channel, signals[SPICE_CHANNEL_EVENT], 0, c->event);
c->event = SPICE_CHANNEL_NONE;
g_clear_error(&c->error);
commit efda5673e0e2b55b4a82cff8d093c96d447ecc00
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Mon Feb 16 17:50:36 2015 +0100
channel: remove useless precondition
This precondition isn't useful, since the channel is already
dereferenced before, and I've never seen an idle callback not passing
the user_data correctly.
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index faaaafe..100f272 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -2179,7 +2179,6 @@ static gboolean spice_channel_delayed_unref(gpointer data)
SpiceChannelPrivate *c = channel->priv;
gboolean was_ready = c->state == SPICE_CHANNEL_STATE_READY;
- g_return_val_if_fail(channel != NULL, FALSE);
CHANNEL_DEBUG(channel, "Delayed unref channel %p", channel);
g_return_val_if_fail(c->coroutine.coroutine.exited == TRUE, FALSE);
commit 63e4b824c5b053bd81c3afe4ec1c1d2e69bc8776
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Mon Feb 16 12:48:51 2015 +0100
channel: emit close event when coroutine has finished
Move signaling of closed channel after the coroutine has exited in
delayed_unref callback, similarly to error events, so it's easier to
schedule reconnect since coroutine has terminated.
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index eec63b1..faaaafe 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -2177,6 +2177,7 @@ static gboolean spice_channel_delayed_unref(gpointer data)
{
SpiceChannel *channel = SPICE_CHANNEL(data);
SpiceChannelPrivate *c = channel->priv;
+ gboolean was_ready = c->state == SPICE_CHANNEL_STATE_READY;
g_return_val_if_fail(channel != NULL, FALSE);
CHANNEL_DEBUG(channel, "Delayed unref channel %p", channel);
@@ -2190,6 +2191,9 @@ static gboolean spice_channel_delayed_unref(gpointer data)
g_clear_error(&c->error);
}
+ if (was_ready)
+ g_coroutine_signal_emit(channel, signals[SPICE_CHANNEL_EVENT], 0, SPICE_CHANNEL_CLOSED);
+
g_object_unref(G_OBJECT(data));
return FALSE;
@@ -2646,9 +2650,6 @@ static void channel_disconnect(SpiceChannel *channel)
c->has_error = TRUE; /* break the loop */
- if (c->state == SPICE_CHANNEL_STATE_READY)
- g_coroutine_signal_emit(channel, signals[SPICE_CHANNEL_EVENT], 0, SPICE_CHANNEL_CLOSED);
-
spice_channel_reset(channel, FALSE);
g_return_if_fail(SPICE_IS_CHANNEL(channel));
More information about the Spice-commits
mailing list