[Spice-commits] 2 commits - gtk/gio-coroutine.h gtk/spice-gtk-session.c

Marc-André Lureau elmarco at kemper.freedesktop.org
Thu May 15 06:00:25 PDT 2014


 gtk/gio-coroutine.h     |   11 +++++++++++
 gtk/spice-gtk-session.c |    4 ++++
 2 files changed, 15 insertions(+)

New commits:
commit 4eb0d20f0ad3f5219385e5b78cf2bc67b247e11e
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Thu May 15 12:46:00 2014 +0200

    clipboard: check that clipboard request does not belong to remote
    
    Check clipboard owner, to avoid cyclic dependency of clipboard requests.

diff --git a/gtk/spice-gtk-session.c b/gtk/spice-gtk-session.c
index 02bdd1e..cf22905 100644
--- a/gtk/spice-gtk-session.c
+++ b/gtk/spice-gtk-session.c
@@ -909,6 +909,9 @@ static gboolean clipboard_request(SpiceMainChannel *main, guint selection,
     GtkClipboard* cb;
     int m;
 
+    g_return_val_if_fail(s->clipboard_by_guest[selection] == FALSE, FALSE);
+    g_return_val_if_fail(s->clip_grabbed[selection], FALSE);
+
     if (read_only(self))
         return FALSE;
 
commit e3efa8cec51045d87a14a7e4f921c24ad5caffb1
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Thu May 15 12:41:33 2014 +0200

    clipboard: prevent reentering main loop if main channel is busy
    
    The main channel must be idle to avoid entering the nested loop,
    or it will never reach the condition to leave it.
    
    This should not happen. It can happen currently when the remote sends a
    clipboard request while the clipboard is grabbed by the remote. In this
    case, while the clipboard-request signal is emitted by main channel, the
    clipboard_get() loop is entered, but the main coroutine will not be
    woken up to proceed with the request, the main channel will remain
    "frozen" and it won't be possible to leave cleanly from the inner loop.
    The application appears to be frozen, because it can't quit properly.
    
    Related to:
    https://bugzilla.redhat.com/show_bug.cgi?id=1083489

diff --git a/gtk/gio-coroutine.h b/gtk/gio-coroutine.h
index 1c4094e..50c1b7c 100644
--- a/gtk/gio-coroutine.h
+++ b/gtk/gio-coroutine.h
@@ -35,6 +35,17 @@ struct _GCoroutine
     guint condition_id;
 };
 
+static inline gboolean g_coroutine_is_idle(GCoroutine *self)
+{
+    gboolean idle;
+
+    g_return_val_if_fail(self != NULL, FALSE);
+
+    idle = self->wait_id != 0 || self->condition_id != 0;
+
+    return idle;
+}
+
 /*
  * A special GSource impl which allows us to wait on a certain
  * condition to be satisfied. This is effectively a boolean test
diff --git a/gtk/spice-gtk-session.c b/gtk/spice-gtk-session.c
index 3574544..02bdd1e 100644
--- a/gtk/spice-gtk-session.c
+++ b/gtk/spice-gtk-session.c
@@ -721,6 +721,7 @@ static void clipboard_get(GtkClipboard *clipboard,
     g_return_if_fail(selection != -1);
     g_return_if_fail(info < SPICE_N_ELEMENTS(atom2agent));
     g_return_if_fail(s->main != NULL);
+    g_return_if_fail(g_coroutine_is_idle(&SPICE_CHANNEL(s->main)->priv->coroutine));
 
     ri.selection_data = selection_data;
     ri.info = info;


More information about the Spice-commits mailing list