From: Victor Toso <me@xxxxxxxxxxxxxx> This patch makes agent_clipboard_grab() to return true only when the message request to the agent is successfully queued to be sent. By checking the return value, we can avoid wakup the channel unnecessarily at spice_main_channel_clipboard_selection_request() Signed-off-by: Victor Toso <victortoso@xxxxxxxxxx> --- src/channel-main.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/channel-main.c b/src/channel-main.c index fb7175e..21afd87 100644 --- a/src/channel-main.c +++ b/src/channel-main.c @@ -1341,8 +1341,9 @@ static void agent_announce_caps(SpiceMainChannel *channel) } /* any context: the message is not flushed immediately, - you can wakeup() the channel coroutine or send_msg_queue() */ -static void agent_clipboard_grab(SpiceMainChannel *channel, guint selection, + you can wakeup() the channel coroutine or send_msg_queue() + Returns true if message was queued. */ +static bool agent_clipboard_grab(SpiceMainChannel *channel, guint selection, guint32 *types, int ntypes) { SpiceMainChannelPrivate *c = channel->priv; @@ -1352,16 +1353,16 @@ static void agent_clipboard_grab(SpiceMainChannel *channel, guint selection, int i; if (!c->agent_connected) - return; + return false; - g_return_if_fail(test_agent_cap(channel, VD_AGENT_CAP_CLIPBOARD_BY_DEMAND)); + g_return_val_if_fail(test_agent_cap(channel, VD_AGENT_CAP_CLIPBOARD_BY_DEMAND), false); size = sizeof(VDAgentClipboardGrab) + sizeof(uint32_t) * ntypes; if (test_agent_cap(channel, VD_AGENT_CAP_CLIPBOARD_SELECTION)) { size += 4; } else if (selection != VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD) { CHANNEL_DEBUG(channel, "Ignoring clipboard grab"); - return; + return false; } msg = g_alloca(size); @@ -1379,6 +1380,7 @@ static void agent_clipboard_grab(SpiceMainChannel *channel, guint selection, } agent_msg_queue(channel, VD_AGENT_CLIPBOARD_GRAB, size, msg); + return true; } /* any context: the message is not flushed immediately, @@ -2771,8 +2773,9 @@ void spice_main_channel_clipboard_selection_grab(SpiceMainChannel *channel, guin g_return_if_fail(channel != NULL); g_return_if_fail(SPICE_IS_MAIN_CHANNEL(channel)); - agent_clipboard_grab(channel, selection, types, ntypes); - spice_channel_wakeup(SPICE_CHANNEL(channel), FALSE); + if (agent_clipboard_grab(channel, selection, types, ntypes)) { + spice_channel_wakeup(SPICE_CHANNEL(channel), FALSE); + } } /** -- 2.19.2 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel