[Spice-devel] [spice-gtk v1 5/9] file-xfer: inform agent of errors only when task finished

Victor Toso victortoso at redhat.com
Thu May 19 11:21:45 UTC 2016


No need to inform of a problem under
spice_file_transfer_task_completed() as the task will be finalized and
we can send the error to the agent there.

This change is related to split SpiceFileTransferTask from
channel-main.
---
 src/channel-main.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/channel-main.c b/src/channel-main.c
index 5f3e27f..28ffe80 100644
--- a/src/channel-main.c
+++ b/src/channel-main.c
@@ -2963,16 +2963,6 @@ static void spice_file_transfer_task_completed(SpiceFileTransferTask *self,
         self->priv->error = error;
     }
 
-    if (self->priv->error) {
-        VDAgentFileXferStatusMessage msg = {
-            .id = self->priv->id,
-            .result = self->priv->error->code == G_IO_ERROR_CANCELLED ?
-                    VD_AGENT_FILE_XFER_STATUS_CANCELLED : VD_AGENT_FILE_XFER_STATUS_ERROR,
-        };
-        agent_msg_queue_many(self->priv->channel, VD_AGENT_FILE_XFER_STATUS,
-                             &msg, sizeof(msg), NULL);
-    }
-
     if (self->priv->pending)
         return;
 
@@ -3093,6 +3083,15 @@ static void task_finished(SpiceFileTransferTask *task,
     SpiceMainChannel *channel = SPICE_MAIN_CHANNEL(data);
     guint32 task_id;
 
+    if (error) {
+        VDAgentFileXferStatusMessage msg;
+        g_object_get(task, "id", &msg.id, NULL);
+        msg.result = error->code == G_IO_ERROR_CANCELLED ?
+                VD_AGENT_FILE_XFER_STATUS_CANCELLED : VD_AGENT_FILE_XFER_STATUS_ERROR;
+        agent_msg_queue_many(channel, VD_AGENT_FILE_XFER_STATUS,
+                             &msg, sizeof(msg), NULL);
+    }
+
     g_object_get(task, "id", &task_id, NULL);
     g_hash_table_remove(channel->priv->file_xfer_tasks, GUINT_TO_POINTER(task_id));
 }
-- 
2.5.5



More information about the Spice-devel mailing list