[Spice-devel] [vdagent-win PATCH 2/2] vdagent: drop clipboard received after timeout

Arnon Gilboa agilboa at redhat.com
Wed May 8 08:01:34 PDT 2013


rhbz #951618
---
 vdagent/vdagent.cpp |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
index 1fad0e6..3c0f829 100644
--- a/vdagent/vdagent.cpp
+++ b/vdagent/vdagent.cpp
@@ -979,9 +979,12 @@ void VDAgent::on_clipboard_request(UINT format)
         event_dispatcher(VD_CLIPBOARD_TIMEOUT_MS, 0);
     }
 
-    cleanup_in_msg();
     if (_clipboard_tick) {
         vd_printf("Clipboard wait timeout");
+        _clipboard_tick = 0;
+    } else {
+        // reset incoming message state only upon completion (even after timeout)
+        cleanup_in_msg();
     }
 }
 
@@ -1303,11 +1306,15 @@ void VDAgent::handle_chunk(VDIChunk* chunk)
         memcpy((uint8_t*)_in_msg + _in_msg_pos, chunk->data, chunk->hdr.size);
         _in_msg_pos += chunk->hdr.size;
         // update clipboard tick on each clipboard chunk for timeout setting
-        if (_in_msg->type == VD_AGENT_CLIPBOARD) {
+        if (_in_msg->type == VD_AGENT_CLIPBOARD && _clipboard_tick) {
             _clipboard_tick = GetTickCount();
         }
         if (_in_msg_pos == sizeof(VDAgentMessage) + _in_msg->size) {
-            dispatch_message(_in_msg, 0);
+            if (_in_msg->type == VD_AGENT_CLIPBOARD && !_clipboard_tick) {
+                vd_printf("Clipboard received but dropped due to timeout");
+            } else {
+                dispatch_message(_in_msg, 0);
+            }
             cleanup_in_msg();
         }
     }
-- 
1.7.7.6



More information about the Spice-devel mailing list