diff options
author | Jonathon Jongsma <jjongsma@redhat.com> | 2016-04-07 15:42:14 -0500 |
---|---|---|
committer | Jonathon Jongsma <jjongsma@redhat.com> | 2016-04-08 09:22:45 -0500 |
commit | 4da4d9201cc3f86e38f00388cdd6157fe70e3328 (patch) | |
tree | 01b465d4050e69f533d2ff6f2233b9cd41147d29 | |
parent | 4c3370bd04b312b0aa26eda8c7af2fa04f4cb99b (diff) |
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().
-rw-r--r-- | src/channel-main.c | 17 |
1 files changed, 10 insertions, 7 deletions
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; |