[Spice-devel] [spice-server 1/3] channel: Call red_channel_disconnect_if_pending_send() from red_channel_wait_all_sent()

Frediano Ziglio fziglio at redhat.com
Fri Sep 1 10:19:28 UTC 2017


> 
> red_channel_disconnect_if_pending_send() and red_channel_wait_all_sent() are
> always called together, we can remove one of the 2 methods.
> 

Looks a good idea but I think that the function deserve a new name

Did you notice the function is always called with the same second parameter?
Does it make sense to pass it?

Frediano

> Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
> ---
>  server/cursor-channel.c |  6 +-----
>  server/red-channel.c    |  1 +
>  server/red-worker.c     | 12 ++----------
>  3 files changed, 4 insertions(+), 15 deletions(-)
> 
> diff --git a/server/cursor-channel.c b/server/cursor-channel.c
> index 8ac5af473..2c449bdcf 100644
> --- a/server/cursor-channel.c
> +++ b/server/cursor-channel.c
> @@ -356,11 +356,7 @@ void cursor_channel_reset(CursorChannel *cursor)
>          if
>          (!common_graphics_channel_get_during_target_migrate(COMMON_GRAPHICS_CHANNEL(cursor)))
>          {
>              red_channel_pipes_add_empty_msg(channel,
>              SPICE_MSG_CURSOR_RESET);
>          }
> -        if (!red_channel_wait_all_sent(channel,
> -                                       COMMON_CLIENT_TIMEOUT)) {
> -            red_channel_apply_clients(channel,
> -
> red_channel_client_disconnect_if_pending_send);
> -        }
> +        red_channel_wait_all_sent(channel, COMMON_CLIENT_TIMEOUT);
>      }
>  }
>  
> diff --git a/server/red-channel.c b/server/red-channel.c
> index a8ab5230e..b9d7f533d 100644
> --- a/server/red-channel.c
> +++ b/server/red-channel.c
> @@ -674,6 +674,7 @@ bool red_channel_wait_all_sent(RedChannel *channel,
>      if (max_pipe_size || blocked) {
>          spice_warning("timeout: pending out messages exist (pipe-size %u,
>          blocked %d)",
>                        max_pipe_size, blocked);
> +        red_channel_apply_clients(channel,
> red_channel_client_disconnect_if_pending_send);
>          return FALSE;
>      } else {
>          spice_assert(red_channel_no_item_being_sent(channel));
> diff --git a/server/red-worker.c b/server/red-worker.c
> index 6ebe6b941..f819c457d 100644
> --- a/server/red-worker.c
> +++ b/server/red-worker.c
> @@ -603,16 +603,8 @@ static void handle_dev_stop(void *opaque, void *payload)
>       * purge the pipe, send destroy_all_surfaces
>       * to the client (there is no such message right now), and start
>       * from scratch on the destination side */
> -    if (!red_channel_wait_all_sent(RED_CHANNEL(worker->display_channel),
> -                                   COMMON_CLIENT_TIMEOUT)) {
> -        red_channel_apply_clients(RED_CHANNEL(worker->display_channel),
> -
> red_channel_client_disconnect_if_pending_send);
> -    }
> -    if (!red_channel_wait_all_sent(RED_CHANNEL(worker->cursor_channel),
> -                                   COMMON_CLIENT_TIMEOUT)) {
> -        red_channel_apply_clients(RED_CHANNEL(worker->cursor_channel),
> -
> red_channel_client_disconnect_if_pending_send);
> -    }
> +    red_channel_wait_all_sent(RED_CHANNEL(worker->display_channel),
> COMMON_CLIENT_TIMEOUT);
> +    red_channel_wait_all_sent(RED_CHANNEL(worker->cursor_channel),
> COMMON_CLIENT_TIMEOUT);
>  }
>  
>  static void handle_dev_start(void *opaque, void *payload)


More information about the Spice-devel mailing list