[Spice-devel] [spice-gtk v4 13/24] file-xfer: inform agent of errors only when task finished

Victor Toso lists at victortoso.com
Fri Jun 24 11:54:04 UTC 2016


Hi,

On Thu, Jun 23, 2016 at 07:37:45PM +0200, Victor Toso wrote:
> 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.
>
> Acked-by: Pavel Grunt <pgrunt at redhat.com>

Please ignore the acked-by as the code changed a bit in this patch by
using g_error_matches() instead of accessing the error->code.

  toso

> ---
>  src/channel-main.c | 23 +++++++++++++----------
>  1 file changed, 13 insertions(+), 10 deletions(-)
> 
> diff --git a/src/channel-main.c b/src/channel-main.c
> index 689b709..117c735 100644
> --- a/src/channel-main.c
> +++ b/src/channel-main.c
> @@ -2990,16 +2990,6 @@ static void spice_file_transfer_task_completed(SpiceFileTransferTask *self,
>          self->error = error;
>      }
>  
> -    if (self->error) {
> -        VDAgentFileXferStatusMessage msg = {
> -            .id = self->id,
> -            .result = self->error->code == G_IO_ERROR_CANCELLED ?
> -                    VD_AGENT_FILE_XFER_STATUS_CANCELLED : VD_AGENT_FILE_XFER_STATUS_ERROR,
> -        };
> -        agent_msg_queue_many(self->channel, VD_AGENT_FILE_XFER_STATUS,
> -                             &msg, sizeof(msg), NULL);
> -    }
> -
>      if (self->pending)
>          return;
>  
> @@ -3117,6 +3107,19 @@ static void file_transfer_operation_task_finished(SpiceFileTransferTask *xfer_ta
>  
>      channel = spice_file_transfer_task_get_channel(xfer_task);
>      task_id = spice_file_transfer_task_get_id(xfer_task);
> +
> +    if (error) {
> +        VDAgentFileXferStatusMessage msg;
> +        msg.id = task_id;
> +        if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
> +            msg.result = VD_AGENT_FILE_XFER_STATUS_CANCELLED;
> +        } else {
> +            msg.result = VD_AGENT_FILE_XFER_STATUS_ERROR;
> +        }
> +        agent_msg_queue_many(channel, VD_AGENT_FILE_XFER_STATUS,
> +                             &msg, sizeof(msg), NULL);
> +    }
> +
>      xfer_op = g_hash_table_lookup(channel->priv->file_xfer_tasks, GUINT_TO_POINTER(task_id));
>      if (xfer_op == NULL) {
>          /* Likely the operation has ended before the remove-task was called. One
> -- 
> 2.7.4
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel


More information about the Spice-devel mailing list