[Spice-devel] [PATCH 4/9] worker: avoid server hanging when no client are connected.

Jonathon Jongsma jjongsma at redhat.com
Wed Dec 9 14:56:26 PST 2015


I've been staring at this patch for a while and I honestly can't figure out how
this change would avoid the server hanging when no clients are connected.
Hopefully somebody more perceptive than me can step in and review this one...


On Wed, 2015-12-09 at 12:17 +0000, Frediano Ziglio wrote:
> From: Marc-André Lureau <marcandre.lureau at gmail.com>
> 
> ---
>  server/red-worker.c | 27 ++++++++++++++++++---------
>  1 file changed, 18 insertions(+), 9 deletions(-)
> 
> diff --git a/server/red-worker.c b/server/red-worker.c
> index 9f2aba1..a57301c 100644
> --- a/server/red-worker.c
> +++ b/server/red-worker.c
> @@ -227,7 +227,6 @@ static int red_process_display(RedWorker *worker, uint32_t
> max_pipe_size, int *r
>  {
>      QXLCommandExt ext_cmd;
>      int n = 0;
> -    uint64_t start = red_get_monotonic_time();
>  
>      if (!worker->running) {
>          *ring_is_empty = TRUE;
> @@ -236,8 +235,23 @@ static int red_process_display(RedWorker *worker,
> uint32_t max_pipe_size, int *r
>  
>      worker->process_display_generation++;
>      *ring_is_empty = FALSE;
> -    while (!display_is_connected(worker) ||
> -           red_channel_max_pipe_size(RED_CHANNEL(worker->display_channel)) <=
> max_pipe_size) {
> +    for (;;) {
> +
> +        if (display_is_connected(worker)) {
> +
> +            if (red_channel_all_blocked(RED_CHANNEL(worker
> ->display_channel))) {
> +                spice_info("all display clients are blocking");
> +                return n;
> +            }
> +
> +
> +            // TODO: change to average pipe size?
> +            if (red_channel_max_pipe_size(RED_CHANNEL(worker
> ->display_channel)) > max_pipe_size) {
> +                spice_info("too many items in the display clients pipe
> already");
> +                return n;
> +            }
> +        }
> +
>          if (!worker->qxl->st->qif->get_command(worker->qxl, &ext_cmd)) {
>              *ring_is_empty = TRUE;;
>              if (worker->display_poll_tries < CMD_RING_POLL_RETRIES) {
> @@ -327,13 +341,8 @@ static int red_process_display(RedWorker *worker,
> uint32_t max_pipe_size, int *r
>              spice_error("bad command type");
>          }
>          n++;
> -        if ((worker->display_channel &&
> -             red_channel_all_blocked(&worker->display_channel->common.base))
> -            || red_get_monotonic_time() - start > 10 * 1000 * 1000) {
> -            worker->event_timeout = 0;
> -            return n;
> -        }
>      }
> +
>      return n;
>  }
>  


More information about the Spice-devel mailing list