If spice-vdagent requests clipboard data while it has previously advertised that it itself can provide it, acknowledge that it's likely a race condition and not a programming error. In this case, release clipboard in spice-gtk as well as vdagent to prevent other apps from requesting data from us when we cannot provide it. Current implementation can cause hangs, as has been reported: https://gitlab.freedesktop.org/spice/win32/vd_agent/issues/6 Related: https://gitlab.freedesktop.org/spice/spice-gtk/issues/82 Related: https://bugzilla.redhat.com/show_bug.cgi?id=1594876 Signed-off-by: Jakub Janků <jjanku@xxxxxxxxxx> --- src/spice-gtk-session.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c index 7b7370c..018cb4b 100644 --- a/src/spice-gtk-session.c +++ b/src/spice-gtk-session.c @@ -1037,7 +1037,18 @@ static gboolean clipboard_request(SpiceMainChannel *main, guint selection, cb = get_clipboard_from_selection(s, selection); g_return_val_if_fail(cb != NULL, FALSE); - g_return_val_if_fail(s->clipboard_by_guest[selection] == FALSE, FALSE); + if (s->clipboard_by_guest[selection]) { + g_warning("%s: 's->clipboard_by_guest[%u] == FALSE' failed, " + "likely a race, releasing clipboard on both sides", + __FUNCTION__, selection); + + spice_main_channel_clipboard_selection_notify(s->main, selection, type, NULL, 0); + spice_main_channel_clipboard_selection_release(s->main, selection); + gtk_clipboard_clear(cb); + s->nclip_targets[selection] = 0; + s->clipboard_by_guest[selection] = FALSE; + return FALSE; + } g_return_val_if_fail(s->clip_grabbed[selection], FALSE); if (read_only(self)) -- 2.20.1 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel