Blame SOURCES/0009-file-xfer-do-not-send-unnecessary-0-bytes-messages.patch

18559f
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
18559f
From: Victor Toso <me@victortoso.com>
18559f
Date: Fri, 11 Nov 2016 14:19:53 +0100
18559f
Subject: [PATCH] file-xfer: do not send unnecessary 0 bytes messages
18559f
18559f
This fixes the situation when VDAgent receives 0 byte message
18559f
regarding a file-transfer operation that was terminated in the
18559f
previous message.
18559f
18559f
This makes the VDAgent to send a STATUS_ERROR after STATUS_SUCCESS to
18559f
client.
18559f
18559f
Resolves: https://bugs.freedesktop.org/show_bug.cgi?id=97227
18559f
18559f
Signed-off-by: Victor Toso <victortoso@redhat.com>
18559f
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
18559f
(cherry picked from commit 885229393e3198bd4b386cf71a51832439dfb31b)
18559f
---
18559f
 src/channel-main.c | 8 ++++++++
18559f
 1 file changed, 8 insertions(+)
18559f
18559f
diff --git a/src/channel-main.c b/src/channel-main.c
18559f
index 990a06a..72ca712 100644
18559f
--- a/src/channel-main.c
18559f
+++ b/src/channel-main.c
18559f
@@ -1822,6 +1822,14 @@ static void file_xfer_read_async_cb(GObject *source_object,
18559f
         return;
18559f
     }
18559f
 
18559f
+    if (count == 0 && spice_file_transfer_task_get_total_bytes(xfer_task) > 0) {
18559f
+        /* If we have sent all payload to the agent, we should not send 0 bytes
18559f
+         * as it will cause https://bugs.freedesktop.org/show_bug.cgi?id=97227.
18559f
+         * Only when file has 0 bytes of size is when we should send 0 bytes to
18559f
+         * agent, see: https://bugzilla.redhat.com/show_bug.cgi?id=1135099 */
18559f
+        return;
18559f
+    }
18559f
+
18559f
     file_xfer_queue_msg_to_agent(channel, spice_file_transfer_task_get_id(xfer_task), buffer, count);
18559f
     if (count == 0 || spice_file_transfer_task_is_completed(xfer_task)) {
18559f
         /* on EOF just wait for VD_AGENT_FILE_XFER_STATUS from agent