[Spice-devel,01/10] worker: don't process drawable if it can't be allocated

Submitted by Frediano Ziglio on Nov. 5, 2015, 9:14 a.m.

Details

Message ID 1446714903-4309-2-git-send-email-fziglio@redhat.com
State New
Headers show
Series "Backported some patches from refactory branches (5th Nov)" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Frediano Ziglio Nov. 5, 2015, 9:14 a.m.
---
 server/red_worker.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/server/red_worker.c b/server/red_worker.c
index 1c37dc0..821ea75 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -3213,14 +3213,14 @@  static inline int red_handle_self_bitmap(RedWorker *worker, Drawable *drawable)
     return TRUE;
 }
 
-static void free_one_drawable(RedWorker *worker, int force_glz_free)
+static bool free_one_drawable(RedWorker *worker, int force_glz_free)
 {
     RingItem *ring_item = ring_get_tail(&worker->current_list);
     Drawable *drawable;
     Container *container;
 
     if (!ring_item) {
-        return;
+        return FALSE;
     }
     drawable = SPICE_CONTAINEROF(ring_item, Drawable, list_link);
     if (force_glz_free) {
@@ -3235,6 +3235,8 @@  static void free_one_drawable(RedWorker *worker, int force_glz_free)
 
     current_remove_drawable(worker, drawable);
     container_cleanup(worker, container);
+
+    return TRUE;
 }
 
 static Drawable *get_drawable(RedWorker *worker, uint8_t effect, RedDrawable *red_drawable,
@@ -3255,7 +3257,8 @@  static Drawable *get_drawable(RedWorker *worker, uint8_t effect, RedDrawable *re
     }
 
     while (!(drawable = alloc_drawable(worker))) {
-        free_one_drawable(worker, FALSE);
+        if (!free_one_drawable(worker, FALSE))
+            return NULL;
     }
     worker->drawable_count++;
     memset(drawable, 0, sizeof(Drawable));
@@ -3358,7 +3361,6 @@  static inline void red_process_draw(RedWorker *worker, RedDrawable *red_drawable
     Drawable *drawable = get_drawable(worker, red_drawable->effect, red_drawable, group_id);
 
     if (!drawable) {
-        rendering_incorrect("failed to get_drawable");
         return;
     }
 

Comments

On Thu, Nov 5, 2015 at 10:14 AM, Frediano Ziglio <fziglio@redhat.com> wrote:
> ---
>  server/red_worker.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/server/red_worker.c b/server/red_worker.c
> index 1c37dc0..821ea75 100644
> --- a/server/red_worker.c
> +++ b/server/red_worker.c
> @@ -3213,14 +3213,14 @@ static inline int red_handle_self_bitmap(RedWorker *worker, Drawable *drawable)
>      return TRUE;
>  }
>
> -static void free_one_drawable(RedWorker *worker, int force_glz_free)
> +static bool free_one_drawable(RedWorker *worker, int force_glz_free)
>  {
>      RingItem *ring_item = ring_get_tail(&worker->current_list);
>      Drawable *drawable;
>      Container *container;
>
>      if (!ring_item) {
> -        return;
> +        return FALSE;
>      }
>      drawable = SPICE_CONTAINEROF(ring_item, Drawable, list_link);
>      if (force_glz_free) {
> @@ -3235,6 +3235,8 @@ static void free_one_drawable(RedWorker *worker, int force_glz_free)
>
>      current_remove_drawable(worker, drawable);
>      container_cleanup(worker, container);
> +
> +    return TRUE;
>  }
>
>  static Drawable *get_drawable(RedWorker *worker, uint8_t effect, RedDrawable *red_drawable,
> @@ -3255,7 +3257,8 @@ static Drawable *get_drawable(RedWorker *worker, uint8_t effect, RedDrawable *re
>      }
>
>      while (!(drawable = alloc_drawable(worker))) {
> -        free_one_drawable(worker, FALSE);
> +        if (!free_one_drawable(worker, FALSE))
> +            return NULL;
>      }
>      worker->drawable_count++;
>      memset(drawable, 0, sizeof(Drawable));
> @@ -3358,7 +3361,6 @@ static inline void red_process_draw(RedWorker *worker, RedDrawable *red_drawable
>      Drawable *drawable = get_drawable(worker, red_drawable->effect, red_drawable, group_id);
>
>      if (!drawable) {
> -        rendering_incorrect("failed to get_drawable");
>          return;
>      }
>
> --
> 2.4.3
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel

Looks good to me, ACK.
> 
> On Thu, Nov 5, 2015 at 10:14 AM, Frediano Ziglio <fziglio@redhat.com> wrote:
> > ---
> >  server/red_worker.c | 10 ++++++----
> >  1 file changed, 6 insertions(+), 4 deletions(-)
> >
> > diff --git a/server/red_worker.c b/server/red_worker.c
> > index 1c37dc0..821ea75 100644
> > --- a/server/red_worker.c
> > +++ b/server/red_worker.c
> > @@ -3213,14 +3213,14 @@ static inline int red_handle_self_bitmap(RedWorker
> > *worker, Drawable *drawable)
> >      return TRUE;
> >  }
> >
> > -static void free_one_drawable(RedWorker *worker, int force_glz_free)
> > +static bool free_one_drawable(RedWorker *worker, int force_glz_free)
> >  {
> >      RingItem *ring_item = ring_get_tail(&worker->current_list);
> >      Drawable *drawable;
> >      Container *container;
> >
> >      if (!ring_item) {
> > -        return;
> > +        return FALSE;
> >      }
> >      drawable = SPICE_CONTAINEROF(ring_item, Drawable, list_link);
> >      if (force_glz_free) {
> > @@ -3235,6 +3235,8 @@ static void free_one_drawable(RedWorker *worker, int
> > force_glz_free)
> >
> >      current_remove_drawable(worker, drawable);
> >      container_cleanup(worker, container);
> > +
> > +    return TRUE;
> >  }
> >
> >  static Drawable *get_drawable(RedWorker *worker, uint8_t effect,
> >  RedDrawable *red_drawable,
> > @@ -3255,7 +3257,8 @@ static Drawable *get_drawable(RedWorker *worker,
> > uint8_t effect, RedDrawable *re
> >      }
> >
> >      while (!(drawable = alloc_drawable(worker))) {
> > -        free_one_drawable(worker, FALSE);
> > +        if (!free_one_drawable(worker, FALSE))
> > +            return NULL;
> >      }
> >      worker->drawable_count++;
> >      memset(drawable, 0, sizeof(Drawable));
> > @@ -3358,7 +3361,6 @@ static inline void red_process_draw(RedWorker
> > *worker, RedDrawable *red_drawable
> >      Drawable *drawable = get_drawable(worker, red_drawable->effect,
> >      red_drawable, group_id);
> >
> >      if (!drawable) {
> > -        rendering_incorrect("failed to get_drawable");
> >          return;
> >      }
> >
> > --
> > 2.4.3

> 
> Looks good to me, ACK.
> 

Merged

Frediano