mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice-gtk
synced 2026-01-01 04:11:24 +00:00
Use macro to swap data in spice_session_start_migrating()
spice_session_start_migrating() swaps connection details between 2 SpiceSession instances. Instead of doing it manually, use a macro to do it for us.
This commit is contained in:
parent
6e86378ec9
commit
01c63439ca
@ -1559,6 +1559,15 @@ void spice_session_switching_disconnect(SpiceSession *self)
|
||||
cache_clear_all(self);
|
||||
}
|
||||
|
||||
#define SWAP_STR(x, y) G_STMT_START { \
|
||||
const gchar *tmp; \
|
||||
const gchar *a = x; \
|
||||
const gchar *b = y; \
|
||||
tmp = a; \
|
||||
a = b; \
|
||||
b = tmp; \
|
||||
} G_STMT_END
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
void spice_session_start_migrating(SpiceSession *session,
|
||||
gboolean full_migration)
|
||||
@ -1567,7 +1576,6 @@ void spice_session_start_migrating(SpiceSession *session,
|
||||
|
||||
SpiceSessionPrivate *s = session->priv;
|
||||
SpiceSessionPrivate *m;
|
||||
gchar *tmp;
|
||||
|
||||
g_return_if_fail(s->migration != NULL);
|
||||
m = s->migration->priv;
|
||||
@ -1578,21 +1586,10 @@ void spice_session_start_migrating(SpiceSession *session,
|
||||
spice_session_set_migration_state(session, SPICE_SESSION_MIGRATION_MIGRATING);
|
||||
|
||||
/* swapping connection details happens after MIGRATION_CONNECTING state */
|
||||
tmp = s->host;
|
||||
s->host = m->host;
|
||||
m->host = tmp;
|
||||
|
||||
tmp = s->port;
|
||||
s->port = m->port;
|
||||
m->port = tmp;
|
||||
|
||||
tmp = s->tls_port;
|
||||
s->tls_port = m->tls_port;
|
||||
m->tls_port = tmp;
|
||||
|
||||
tmp = s->unix_path;
|
||||
s->unix_path = m->unix_path;
|
||||
m->unix_path = tmp;
|
||||
SWAP_STR(s->host, m->host);
|
||||
SWAP_STR(s->port, m->port);
|
||||
SWAP_STR(s->tls_port, m->tls_port);
|
||||
SWAP_STR(s->unix_path, m->unix_path);
|
||||
|
||||
g_warn_if_fail(ring_get_length(&s->channels) == ring_get_length(&m->channels));
|
||||
|
||||
@ -1600,6 +1597,7 @@ void spice_session_start_migrating(SpiceSession *session,
|
||||
ring_get_length(&s->channels), ring_get_length(&m->channels));
|
||||
s->migration_left = spice_session_get_channels(session);
|
||||
}
|
||||
#undef SWAP_STR
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
SpiceChannel* spice_session_lookup_channel(SpiceSession *session, gint id, gint type)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user