Re: [spice-gtk v2 1/7] gtk-session: prefer early check to agent connectivity

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/10/18 1:02 PM, Victor Toso wrote:
From: Victor Toso <me@xxxxxxxxxxxxxx>

In case the agent is disconnected, we we don't need to create the

we we -> we

struct RunInfo, GMainLoop and add handlers to some signals.

Before this patch, spice_main_channel_clipboard_selection_request()
was always called even if agent was not connected, which would log
a critical message in agent_clipboard_request() and unnecessary call
to spice_channel_wakeup().

This patch also removes one goto and related cleanup label.

Changes in v2:
- Improved commit log based on a function call that is now avoided:
   spice_main_channel_clipboard_selection_request (Frediano)

Signed-off-by: Victor Toso <victortoso@xxxxxxxxxx>

Looks good to me.

Uri.

---
  src/spice-gtk-session.c | 14 ++++++--------
  1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
index 1ccae07..373d11e 100644
--- a/src/spice-gtk-session.c
+++ b/src/spice-gtk-session.c
@@ -728,6 +728,12 @@ static void clipboard_get(GtkClipboard *clipboard,
      g_return_if_fail(info < SPICE_N_ELEMENTS(atom2agent));
      g_return_if_fail(s->main != NULL);
+ g_object_get(s->main, "agent-connected", &agent_connected, NULL);
+    if (!agent_connected) {
+        SPICE_DEBUG("Request to guest failed as agent is not running");
+        return;
+    }
+
      ri.selection_data = selection_data;
      ri.info = info;
      ri.loop = g_main_loop_new(NULL, FALSE);
@@ -744,13 +750,6 @@ static void clipboard_get(GtkClipboard *clipboard,
      spice_main_channel_clipboard_selection_request(s->main, selection,
                                                     atom2agent[info].vdagent);
-
-    g_object_get(s->main, "agent-connected", &agent_connected, NULL);
-    if (!agent_connected) {
-        SPICE_DEBUG("canceled clipboard_get, before running loop");
-        goto cleanup;
-    }
-
      /* This is modeled on the implementation of gtk_dialog_run() even though
       * these thread functions are deprecated and appears to be needed to avoid
       * dead-lock from gtk_dialog_run().
@@ -761,7 +760,6 @@ static void clipboard_get(GtkClipboard *clipboard,
      gdk_threads_enter();
      G_GNUC_END_IGNORE_DEPRECATIONS
-cleanup:
      g_clear_pointer(&ri.loop, g_main_loop_unref);
      g_signal_handler_disconnect(s->main, clipboard_handler);
      g_signal_handler_disconnect(s->main, agent_handler);


_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]