diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2010-09-24 17:53:34 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2010-09-24 17:53:34 +0200 |
commit | 4f0c0fef099155cf3a59b7ee58f697c3cadf98fd (patch) | |
tree | 6e14f5cb20cecd70754a60c1644ce9337bf7bcaf | |
parent | 1d5efac7202828f9df6bac4478ee7a78714a4f51 (diff) |
misc
-rw-r--r-- | gtk/spice-session.c | 19 | ||||
-rw-r--r-- | gtk/spicy.c | 1 |
2 files changed, 13 insertions, 7 deletions
diff --git a/gtk/spice-session.c b/gtk/spice-session.c index 9efe2c2..5f67883 100644 --- a/gtk/spice-session.c +++ b/gtk/spice-session.c @@ -21,6 +21,7 @@ struct spice_session { char *ca_file; struct addrinfo ai; int connection_id; + SpiceChannel *cmain; Ring channels; }; @@ -259,25 +260,31 @@ SpiceSession *spice_session_new() gboolean spice_session_connect(SpiceSession *session) { - SpiceChannel *cmain; + spice_session *s = SPICE_SESSION_GET_PRIVATE(session); spice_session_disconnect(session); - cmain = spice_channel_new(session, SPICE_CHANNEL_MAIN, 0); - return spice_channel_connect(cmain); + s->cmain = spice_channel_new(session, SPICE_CHANNEL_MAIN, 0); + return spice_channel_connect(s->cmain); } void spice_session_disconnect(SpiceSession *session) { spice_session *s = SPICE_SESSION_GET_PRIVATE(session); struct channel *item; - RingItem *ring; + RingItem *ring, *next; - while (!ring_is_empty(&s->channels)) { - ring = ring_get_head(&s->channels); + if (s->cmain == NULL) { + return; + } + + for (ring = ring_get_head(&s->channels); ring != NULL; ring = next) { + next = ring_next(&s->channels, ring); item = SPICE_CONTAINEROF(ring, struct channel, link); spice_channel_destroy(item->channel); } + s->connection_id = 0; + s->cmain = NULL; } int spice_session_get_channels(SpiceSession *session, SpiceChannel **channels, int max) diff --git a/gtk/spicy.c b/gtk/spicy.c index b13bee6..1d3689b 100644 --- a/gtk/spicy.c +++ b/gtk/spicy.c @@ -366,7 +366,6 @@ static void main_channel_event(SpiceChannel *channel, enum SpiceChannelEvent eve password, sizeof(password), true); if (rc == 0) { g_object_set(session, "password", password, NULL); - spice_session_disconnect(session); spice_session_connect(session); } else { g_main_loop_quit(mainloop); |