[Spice-devel] [PATCH spice-gtk 2/5] vmcstream: finish task immediately when reading 0 bytes

Frediano Ziglio fziglio at redhat.com
Tue Jun 18 10:30:41 UTC 2019


> 
> The current implementation finishes it
> only after new data arrives from the channel (or after it is cancelled).
> 

Minor: weird split of long line

> Signed-off-by: Jakub Janků <jjanku at redhat.com>
> ---
>  src/vmcstream.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/src/vmcstream.c b/src/vmcstream.c
> index 86c949a..451d06e 100644
> --- a/src/vmcstream.c
> +++ b/src/vmcstream.c
> @@ -201,14 +201,21 @@ spice_vmc_input_stream_read_all_async(GInputStream
> *stream,
>  
>      /* no concurrent read permitted by ginputstream */
>      g_return_if_fail(self->task == NULL);
> -    self->all = TRUE;
> -    self->buffer = buffer;
> -    self->count = count;
> -    self->pos = 0;
> +

Why you changed this? I think these fields won't be used if
count == 0 but I would prefer if they contain the values
of the last call. Also this reduce code changes.

>      task = g_task_new(self,
>                        cancellable,
>                        callback,
>                        user_data);
> +    if (count == 0) {
> +        g_task_return_int(task, 0);
> +        g_object_unref(task);
> +        return;
> +    }
> +
> +    self->all = TRUE;
> +    self->buffer = buffer;
> +    self->count = count;
> +    self->pos = 0;
>      self->task = task;
>      if (cancellable)
>          self->cancel_id =

Otherwise patch is fine.

Frediano


More information about the Spice-devel mailing list