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

Jonathon Jongsma jjongsma at redhat.com
Wed Jan 20 15:24:57 PST 2016


On Wed, 2016-01-20 at 11:46 -0500, 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 a98c4a6..991a816 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 = spice_get_monotonic_time_ns();
> >  
> >      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))
> > -            || spice_get_monotonic_time_ns() - start > NSEC_PER_SEC / 100)
> > {
> > -            worker->event_timeout = 0;
> > -            return n;
> > -        }
> >      }
> > +
> >      return n;
> >  }
> >  
> 
> I don't remember why I have this patch still around.
> 
> Frediano


As far as I remember, This was originally bundled with the glib loop patch but
we split it off because it wasn't strictly related to the glib loop stuff. I've
never been particularly confident in what this patch is trying to accomplish,
and the last time it came up, you were not particularly convinced either: 
http://lists.freedesktop.org/archives/spice-devel/2015-December/024819.html


Jonathon



More information about the Spice-devel mailing list