[Spice-commits] src/channel-main.c

Jonathon Jongsma jjongsma at kemper.freedesktop.org
Fri Apr 8 14:23:36 UTC 2016


 src/channel-main.c |   17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

New commits:
commit 4da4d9201cc3f86e38f00388cdd6157fe70e3328
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date:   Thu Apr 7 15:42:14 2016 -0500

    Ensure that file transfers get cancelled
    
    When canceling a file transfer task in spicy, the client would often
    stop sending additional data, but it would not send a "CANCELLED"
    message to the guest. Because of this, the partial file would remain in
    the guest's downloads folder until the spice client disconnected, at
    which point the vdagent would remove the unfinshed file.
    
    This CANCELLED status message was only being sent if the task was
    canceled during the async file read operation. If you cancel a task,
    it's quite likely that it will happen during other operations
    (e.g. file_xfer_flush_async(), etc). In order to handle these scenarios
    (and make sure that the file gets canceled properly), send the
    FILE_XFER_STATUS message in spice_file_transfer_task_completed().

diff --git a/src/channel-main.c b/src/channel-main.c
index 955b358..8e5de8a 100644
--- a/src/channel-main.c
+++ b/src/channel-main.c
@@ -1910,13 +1910,6 @@ static void file_xfer_read_cb(GObject *source_object,
                               file_xfer_data_flushed_cb, self);
         self->priv->pending = TRUE;
     } else if (error) {
-        VDAgentFileXferStatusMessage msg = {
-            .id = self->priv->id,
-            .result = 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);
         spice_channel_wakeup(SPICE_CHANNEL(self->priv->channel), FALSE);
         spice_file_transfer_task_completed(self, error);
     }
@@ -2942,6 +2935,16 @@ static void spice_file_transfer_task_completed(SpiceFileTransferTask *self,
         self->priv->error = error;
     }
 
+    if (self->priv->error) {
+        VDAgentFileXferStatusMessage msg = {
+            .id = self->priv->id,
+            .result = 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;
 


More information about the Spice-commits mailing list