[Spice-devel] [PATCH spice-gtk] Remove extra checks before g_cancellable_disconnect()

Victor Toso lists at victortoso.com
Tue Mar 22 10:37:05 UTC 2016


Hi,

On Mon, Mar 21, 2016 at 01:50:55PM +0100, Pavel Grunt wrote:
> If cancellable is NULL or handler_id is 0 the function does nothing.

Acked-by: Victor Toso <victortoso at redhat.com>

> ---
>  src/spice-pulse.c |  4 +---
>  src/vmcstream.c   | 15 +++------------
>  2 files changed, 4 insertions(+), 15 deletions(-)
> 
> diff --git a/src/spice-pulse.c b/src/spice-pulse.c
> index 8d45dbe..6bc3014 100644
> --- a/src/spice-pulse.c
> +++ b/src/spice-pulse.c
> @@ -945,9 +945,7 @@ static gboolean free_async_task(gpointer user_data)
>      if (task->pa_op != NULL)
>          pa_operation_unref(task->pa_op);
>  
> -    if (task->cancel_id != 0)
> -        g_cancellable_disconnect(g_task_get_cancellable(task->gtask),
> -                                 task->cancel_id);
> +    g_cancellable_disconnect(g_task_get_cancellable(task->gtask), task->cancel_id);
>  
>      if (task->gtask)
>          g_object_unref(task->gtask);
> diff --git a/src/vmcstream.c b/src/vmcstream.c
> index 48f9513..a206961 100644
> --- a/src/vmcstream.c
> +++ b/src/vmcstream.c
> @@ -116,7 +116,6 @@ spice_vmc_input_stream_co_data(SpiceVmcInputStream *self,
>      self->coroutine = coroutine_self();
>  
>      while (size > 0) {
> -        GCancellable *cancellable;
>          SPICE_DEBUG("spicevmc co_data %p", self->task);
>          if (!self->task)
>              coroutine_yield(NULL);
> @@ -140,9 +139,7 @@ spice_vmc_input_stream_co_data(SpiceVmcInputStream *self,
>  
>          g_task_return_int(self->task, self->pos);
>  
> -        cancellable = g_task_get_cancellable(self->task);
> -        if (cancellable)
> -            g_cancellable_disconnect(cancellable, self->cancel_id);
> +        g_cancellable_disconnect(g_task_get_cancellable(self->task), self->cancel_id);
>  
>          g_clear_object(&self->task);
>      }
> @@ -208,16 +205,13 @@ spice_vmc_input_stream_read_all_finish(GInputStream *stream,
>                                         GError **error)
>  {
>      GTask *task = G_TASK(result);
> -    GCancellable *cancellable;
>      SpiceVmcInputStream *self = SPICE_VMC_INPUT_STREAM(stream);
>  
>      g_return_val_if_fail(g_task_is_valid(task, self), -1);
>  
>      /* FIXME: calling _finish() is required. Disconnecting in
>         read_cancelled() causes a deadlock. #705395 */
> -    cancellable = g_task_get_cancellable(task);
> -    if (cancellable)
> -        g_cancellable_disconnect(cancellable, self->cancel_id);
> +    g_cancellable_disconnect(g_task_get_cancellable(task), self->cancel_id);
>  
>      return g_task_propagate_int(task, error);
>  }
> @@ -258,16 +252,13 @@ spice_vmc_input_stream_read_finish(GInputStream *stream,
>                                     GError **error)
>  {
>      GTask *task = G_TASK(result);
> -    GCancellable *cancellable;
>      SpiceVmcInputStream *self = SPICE_VMC_INPUT_STREAM(stream);
>  
>      g_return_val_if_fail(g_task_is_valid(task, self), -1);
>  
>      /* FIXME: calling _finish() is required. Disconnecting in
>         read_cancelled() causes a deadlock. #705395 */
> -    cancellable = g_task_get_cancellable(task);
> -    if (cancellable)
> -        g_cancellable_disconnect(cancellable, self->cancel_id);
> +    g_cancellable_disconnect(g_task_get_cancellable(task), self->cancel_id);
>  
>      return g_task_propagate_int(task, error);
>  }
> -- 
> 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