[Spice-commits] 6 commits - server/red_channel.c server/red_channel.h server/red_worker.c

Frediano Ziglio fziglio at kemper.freedesktop.org
Thu Oct 15 10:32:47 PDT 2015


 server/red_channel.c |    9 +
 server/red_channel.h |    6 +
 server/red_worker.c  |  280 +--------------------------------------------------
 3 files changed, 25 insertions(+), 270 deletions(-)

New commits:
commit f93bf94c5caa5bd7da14343fa5e27fb31d7f0941
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Tue Sep 10 21:35:56 2013 +0200

    Remove PIPE_DEBUG
    
    Acked-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

diff --git a/server/red_worker.c b/server/red_worker.c
index 9ed54f5..c96c60a 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -95,7 +95,6 @@
 
 //#define COMPRESS_STAT
 //#define DUMP_BITMAP
-//#define PIPE_DEBUG
 //#define RED_WORKER_STAT
 /* TODO: DRAW_ALL is broken. */
 //#define DRAW_ALL
@@ -781,9 +780,6 @@ typedef struct TreeItem {
     uint32_t type;
     struct Container *container;
     QRegion rgn;
-#ifdef PIPE_DEBUG
-    uint32_t id;
-#endif
 } TreeItem;
 
 #define IS_DRAW_ITEM(item) ((item)->type == TREE_ITEM_TYPE_DRAWABLE)
@@ -1006,9 +1002,6 @@ typedef struct RedWorker {
     ZlibEncoder *zlib;
 
     uint32_t process_commands_generation;
-#ifdef PIPE_DEBUG
-    uint32_t last_id;
-#endif
 #ifdef RED_WORKER_STAT
     stat_info_t add_stat;
     stat_info_t exclude_stat;
@@ -2126,95 +2119,6 @@ static void red_clear_surface_drawables_from_pipes(RedWorker *worker,
     }
 }
 
-#ifdef PIPE_DEBUG
-
-static void print_rgn(const char* prefix, const QRegion* rgn)
-{
-    int i;
-    printf("TEST: %s: RGN: bbox %u %u %u %u\n",
-           prefix,
-           rgn->bbox.top,
-           rgn->bbox.left,
-           rgn->bbox.bottom,
-           rgn->bbox.right);
-
-    for (i = 0; i < rgn->num_rects; i++) {
-        printf("TEST: %s: RECT %u %u %u %u\n",
-               prefix,
-               rgn->rects[i].top,
-               rgn->rects[i].left,
-               rgn->rects[i].bottom,
-               rgn->rects[i].right);
-    }
-}
-
-static void print_draw_item(const char* prefix, const DrawItem *draw_item)
-{
-    const TreeItem *base = &draw_item->base;
-    const Drawable *drawable = SPICE_CONTAINEROF(draw_item, Drawable, tree_item);
-    printf("TEST: %s: draw id %u container %u effect %u",
-           prefix,
-           base->id, base->container ? base->container->base.id : 0,
-           draw_item->effect);
-    if (draw_item->shadow) {
-        printf(" shadow %u\n", draw_item->shadow->base.id);
-    } else {
-        printf("\n");
-    }
-    print_rgn(prefix, &base->rgn);
-}
-
-static void print_shadow_item(const char* prefix, const Shadow *item)
-{
-    printf("TEST: %s: shadow %p id %d\n", prefix, item, item->base.id);
-    print_rgn(prefix, &item->base.rgn);
-}
-
-static void print_container_item(const char* prefix, const Container *item)
-{
-    printf("TEST: %s: container %p id %d\n", prefix, item, item->base.id);
-    print_rgn(prefix, &item->base.rgn);
-}
-
-static void print_base_item(const char* prefix, const TreeItem *base)
-{
-    switch (base->type) {
-    case TREE_ITEM_TYPE_DRAWABLE:
-        print_draw_item(prefix, (const DrawItem *)base);
-        break;
-    case TREE_ITEM_TYPE_SHADOW:
-        print_shadow_item(prefix, (const Shadow *)base);
-        break;
-    case TREE_ITEM_TYPE_CONTAINER:
-        print_container_item(prefix, (const Container *)base);
-        break;
-    default:
-        spice_error("invalid type %u", base->type);
-    }
-}
-
-void __show_current(TreeItem *item, void *data)
-{
-    print_base_item("TREE", item);
-}
-
-static void show_current(RedWorker *worker, Ring *ring)
-{
-    if (ring_is_empty(ring)) {
-        spice_info("TEST: TREE: EMPTY");
-        return;
-    }
-    current_tree_for_each(ring, __show_current, NULL);
-}
-
-#else
-#define print_rgn(a, b)
-#define print_draw_private(a, b)
-#define show_current(a, r)
-#define print_shadow_item(a, b)
-#define print_base_item(a, b)
-#endif
-
 static inline Shadow *__find_shadow(TreeItem *item)
 {
     while (item->type == TREE_ITEM_TYPE_CONTAINER) {
@@ -2340,14 +2244,11 @@ static void exclude_region(RedWorker *worker, Ring *ring, RingItem *ring_item, Q
         spice_assert(!region_is_empty(&now->rgn));
 
         if (region_intersects(rgn, &now->rgn)) {
-            print_base_item("EXCLUDE2", now);
             __exclude_region(worker, ring, now, rgn, &top_ring, frame_candidate);
-            print_base_item("EXCLUDE3", now);
 
             if (region_is_empty(&now->rgn)) {
                 spice_assert(now->type != TREE_ITEM_TYPE_SHADOW);
                 ring_item = now->siblings_link.prev;
-                print_base_item("EXCLUDE_REMOVE", now);
                 current_remove(worker, now);
                 if (last && *last == now) {
                     *last = (TreeItem *)ring_next(ring, ring_item);
@@ -2385,9 +2286,6 @@ static inline Container *__new_container(RedWorker *worker, DrawItem *item)
 {
     Container *container = spice_new(Container, 1);
     worker->containers_count++;
-#ifdef PIPE_DEBUG
-    container->base.id = ++worker->last_id;
-#endif
     container->base.type = TREE_ITEM_TYPE_CONTAINER;
     container->base.container = item->base.container;
     item->base.container = container;
@@ -3649,7 +3547,6 @@ static inline int red_current_add(RedWorker *worker, Ring *ring, Drawable *drawa
     QRegion exclude_rgn;
     RingItem *exclude_base = NULL;
 
-    print_base_item("ADD", &item->base);
     spice_assert(!region_is_empty(&item->base.rgn));
     region_init(&exclude_rgn);
     now = ring_next(ring, ring);
@@ -3659,13 +3556,11 @@ static inline int red_current_add(RedWorker *worker, Ring *ring, Drawable *drawa
         int test_res;
 
         if (!region_bounds_intersects(&item->base.rgn, &sibling->rgn)) {
-            print_base_item("EMPTY", sibling);
             now = ring_next(ring, now);
             continue;
         }
         test_res = region_test(&item->base.rgn, &sibling->rgn, REGION_TEST_ALL);
         if (!(test_res & REGION_TEST_SHARED)) {
-            print_base_item("EMPTY", sibling);
             now = ring_next(ring, now);
             continue;
         } else if (sibling->type != TREE_ITEM_TYPE_SHADOW) {
@@ -3679,7 +3574,6 @@ static inline int red_current_add(RedWorker *worker, Ring *ring, Drawable *drawa
             if (!(test_res & REGION_TEST_RIGHT_EXCLUSIVE) && item->effect == QXL_EFFECT_OPAQUE) {
                 Shadow *shadow;
                 int skip = now == exclude_base;
-                print_base_item("CONTAIN", sibling);
 
                 if ((shadow = __find_shadow(sibling))) {
                     if (exclude_base) {
@@ -3710,7 +3604,6 @@ static inline int red_current_add(RedWorker *worker, Ring *ring, Drawable *drawa
                     region_clear(&exclude_rgn);
                     exclude_base = NULL;
                 }
-                print_base_item("IN", sibling);
                 if (sibling->type == TREE_ITEM_TYPE_CONTAINER) {
                     container = (Container *)sibling;
                     ring = &container->items;
@@ -3780,9 +3673,6 @@ static inline Shadow *__new_shadow(RedWorker *worker, Drawable *item, SpicePoint
 
     Shadow *shadow = spice_new(Shadow, 1);
     worker->shadows_count++;
-#ifdef PIPE_DEBUG
-    shadow->base.id = ++worker->last_id;
-#endif
     shadow->base.type = TREE_ITEM_TYPE_SHADOW;
     shadow->base.container = NULL;
     shadow->owner = &item->tree_item;
@@ -3806,7 +3696,6 @@ static inline int red_current_add_with_shadow(RedWorker *worker, Ring *ring, Dra
         stat_add(&worker->add_stat, start_time);
         return FALSE;
     }
-    print_base_item("ADDSHADOW", &item->tree_item.base);
     // item and his shadow must initially be placed in the same container.
     // for now putting them on root.
 
@@ -4072,9 +3961,6 @@ static Drawable *get_drawable(RedWorker *worker, uint8_t effect, RedDrawable *re
     drawable->refs = 1;
     clock_gettime(CLOCK_MONOTONIC, &time);
     drawable->creation_time = timespec_to_red_time(&time);
-#ifdef PIPE_DEBUG
-    drawable->tree_item.base.id = ++worker->last_id;
-#endif
     ring_item_init(&drawable->list_link);
     ring_item_init(&drawable->surface_list_link);
     ring_item_init(&drawable->tree_item.base.siblings_link);
@@ -4182,14 +4068,6 @@ static inline void red_process_drawable(RedWorker *worker, RedDrawable *red_draw
     worker->surfaces[surface_id].refs++;
 
     region_add(&drawable->tree_item.base.rgn, &red_drawable->bbox);
-#ifdef PIPE_DEBUG
-    printf("TEST: DRAWABLE: id %u type %s effect %u bbox %u %u %u %u\n",
-           drawable->tree_item.base.id,
-           draw_type_to_str(red_drawable->type),
-           drawable->tree_item.effect,
-           red_drawable->bbox.top, red_drawable->bbox.left,
-           red_drawable->bbox.bottom, red_drawable->bbox.right);
-#endif
 
     if (red_drawable->clip.type == SPICE_CLIP_TYPE_RECTS) {
         QRegion rgn;
commit dc1e589916aae32afdcd373d8609be8096682d28
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Tue Sep 10 19:51:11 2013 +0200

    Remove ACYCLIC_SURFACE_DEBUG
    
    Acked-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

diff --git a/server/red_worker.c b/server/red_worker.c
index ce96449..9ed54f5 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -100,7 +100,6 @@
 /* TODO: DRAW_ALL is broken. */
 //#define DRAW_ALL
 //#define COMPRESS_DEBUG
-//#define ACYCLIC_SURFACE_DEBUG
 //#define DEBUG_CURSORS
 
 #define CMD_RING_POLL_TIMEOUT 10 //milli
@@ -895,9 +894,6 @@ typedef struct RedSurface {
     uint32_t refs;
     Ring current;
     Ring current_list;
-#ifdef ACYCLIC_SURFACE_DEBUG
-    int current_gn;
-#endif
     DrawContext context;
 
     Ring depend_on_me;
@@ -4637,9 +4633,6 @@ static void red_update_area(RedWorker *worker, const SpiceRect *area, int surfac
     QRegion rgn;
     Drawable *last;
     Drawable *now;
-#ifdef ACYCLIC_SURFACE_DEBUG
-    int gn;
-#endif
     spice_debug("surface %d: area ==>", surface_id);
     rect_debug(area);
 
@@ -4651,9 +4644,6 @@ static void red_update_area(RedWorker *worker, const SpiceRect *area, int surfac
     surface = &worker->surfaces[surface_id];
 
     last = NULL;
-#ifdef ACYCLIC_SURFACE_DEBUG
-    gn = ++surface->current_gn;
-#endif
     ring = &surface->current_list;
     ring_item = ring;
 
@@ -4684,11 +4674,6 @@ static void red_update_area(RedWorker *worker, const SpiceRect *area, int surfac
         container_cleanup(worker, container);
         red_draw_drawable(worker, now);
         release_drawable(worker, now);
-#ifdef ACYCLIC_SURFACE_DEBUG
-        if (gn != surface->current_gn) {
-            spice_error("cyclic surface dependencies");
-        }
-#endif
     } while (now != last);
     validate_area(worker, area, surface_id);
 }
commit 3dffeb25edc9d7a893d9697fc7b19739aff36cc9
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Tue Sep 10 19:50:06 2013 +0200

    Remove unfinished UPDATE_AREA_BY_TREE
    
    Acked-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

diff --git a/server/red_worker.c b/server/red_worker.c
index f5cfa7c..ce96449 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -103,8 +103,6 @@
 //#define ACYCLIC_SURFACE_DEBUG
 //#define DEBUG_CURSORS
 
-//#define UPDATE_AREA_BY_TREE
-
 #define CMD_RING_POLL_TIMEOUT 10 //milli
 #define CMD_RING_POLL_RETRIES 200
 
@@ -838,9 +836,6 @@ struct Drawable {
     Ring pipes;
     PipeItem *pipe_item_rest;
     uint32_t size_pipe_item_rest;
-#ifdef UPDATE_AREA_BY_TREE
-    RingItem collect_link;
-#endif
     RedDrawable *red_drawable;
 
     Ring glz_ring;
@@ -4086,9 +4081,6 @@ static Drawable *get_drawable(RedWorker *worker, uint8_t effect, RedDrawable *re
 #endif
     ring_item_init(&drawable->list_link);
     ring_item_init(&drawable->surface_list_link);
-#ifdef UPDATE_AREA_BY_TREE
-    ring_item_init(&drawable->collect_link);
-#endif
     ring_item_init(&drawable->tree_item.base.siblings_link);
     drawable->tree_item.base.type = TREE_ITEM_TYPE_DRAWABLE;
     region_init(&drawable->tree_item.base.rgn);
@@ -4529,19 +4521,8 @@ static void red_draw_qxl_drawable(RedWorker *worker, Drawable *drawable)
 
 static void red_draw_drawable(RedWorker *worker, Drawable *drawable)
 {
-#ifdef UPDATE_AREA_BY_TREE
-    SpiceCanvas *canvas;
-
-    canvas = surface->context.canvas;
-    //todo: add need top mask flag
-    canvas->ops->group_start(canvas,
-                             &drawable->tree_item.base.rgn);
-#endif
     red_flush_source_surfaces(worker, drawable);
     red_draw_qxl_drawable(worker, drawable);
-#ifdef UPDATE_AREA_BY_TREE
-    canvas->ops->group_end(canvas);
-#endif
 }
 
 static void validate_area(RedWorker *worker, const SpiceRect *area, uint32_t surface_id)
@@ -4566,93 +4547,6 @@ static void validate_area(RedWorker *worker, const SpiceRect *area, uint32_t sur
     }
 }
 
-#ifdef UPDATE_AREA_BY_TREE
-
-static inline void __red_collect_for_update(RedWorker *worker, Ring *ring, RingItem *ring_item,
-                                            QRegion *rgn, Ring *items)
-{
-    Ring *top_ring = ring;
-
-    for (;;) {
-        TreeItem *now = SPICE_CONTAINEROF(ring_item, TreeItem, siblings_link);
-        Container *container = now->container;
-        if (region_intersects(rgn, &now->rgn)) {
-            if (IS_DRAW_ITEM(now)) {
-                Drawable *drawable = SPICE_CONTAINEROF(now, Drawable, tree_item);
-
-                ring_add(items, &drawable->collect_link);
-                region_or(rgn, &now->rgn);
-                if (drawable->tree_item.shadow) {
-                    region_or(rgn, &drawable->tree_item.shadow->base.rgn);
-                }
-            } else if (now->type == TREE_ITEM_TYPE_SHADOW) {
-                Drawable *owner = SPICE_CONTAINEROF(((Shadow *)now)->owner, Drawable, tree_item);
-                if (!ring_item_is_linked(&owner->collect_link)) {
-                    region_or(rgn, &now->rgn);
-                    region_or(rgn, &owner->tree_item.base.rgn);
-                    ring_add(items, &owner->collect_link);
-                }
-            } else if (now->type == TREE_ITEM_TYPE_CONTAINER) {
-                Container *container = (Container *)now;
-
-                if ((ring_item = ring_get_head(&container->items))) {
-                    ring = &container->items;
-                    spice_assert(((TreeItem *)ring_item)->container);
-                    continue;
-                }
-                ring_item = &now->siblings_link;
-            }
-        }
-
-        while (!(ring_item = ring_next(ring, ring_item))) {
-            if (ring == top_ring) {
-                return;
-            }
-            ring_item = &container->base.siblings_link;
-            container = container->base.container;
-            ring = (container) ? &container->items : top_ring;
-        }
-    }
-}
-
-static void red_update_area(RedWorker *worker, const SpiceRect *area, int surface_id)
-{
-    RedSurface *surface;
-    Ring *ring;
-    RingItem *ring_item;
-    Ring items;
-    QRegion rgn;
-
-    surface = &worker->surfaces[surface_id];
-    ring = &surface->current;
-
-    if (!(ring_item = ring_get_head(ring))) {
-        worker->draw_context.validate_area(surface->context.canvas,
-                                           &worker->dev_info.surface0_area, area);
-        return;
-    }
-
-    region_init(&rgn);
-    region_add(&rgn, area);
-    ring_init(&items);
-    __red_collect_for_update(worker, ring, ring_item, &rgn, &items);
-    region_destroy(&rgn);
-
-    while ((ring_item = ring_get_head(&items))) {
-        Drawable *drawable = SPICE_CONTAINEROF(ring_item, Drawable, collect_link);
-        Container *container;
-
-        ring_remove(ring_item);
-        red_draw_drawable(worker, drawable);
-        container = drawable->tree_item.base.container;
-        current_remove_drawable(worker, drawable);
-        container_cleanup(worker, container);
-    }
-    validate_area(worker, area, surface_id);
-}
-
-#else
-
 /*
     Renders drawables for updating the requested area, but only drawables that are older
     than 'last' (exclusive).
@@ -4660,9 +4554,6 @@ static void red_update_area(RedWorker *worker, const SpiceRect *area, int surfac
 static void red_update_area_till(RedWorker *worker, const SpiceRect *area, int surface_id,
                                  Drawable *last)
 {
-    // TODO: if we use UPDATE_AREA_BY_TREE, a corresponding red_update_area_till
-    // should be implemented
-
     RedSurface *surface;
     Drawable *surface_last = NULL;
     Ring *ring;
@@ -4803,7 +4694,6 @@ static void red_update_area(RedWorker *worker, const SpiceRect *area, int surfac
 }
 
 #endif
-#endif
 
 static inline void free_cursor_item(RedWorker *worker, CursorItem *item);
 
commit c1d518139699081f87d15cdb8c027e5e2c14ff5c
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Thu Feb 27 19:38:41 2014 +0200

    server: small move to red_channel
    
    Acked-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

diff --git a/server/red_channel.c b/server/red_channel.c
index 3f40fab..8db3d6e 100644
--- a/server/red_channel.c
+++ b/server/red_channel.c
@@ -2429,3 +2429,12 @@ int red_channel_wait_all_sent(RedChannel *channel,
         return TRUE;
     }
 }
+
+void red_channel_client_disconnect_if_pending_send(RedChannelClient *rcc)
+{
+    if (red_channel_client_blocked(rcc) || rcc->pipe_size > 0) {
+        red_channel_client_disconnect(rcc);
+    } else {
+        spice_assert(red_channel_client_no_item_being_sent(rcc));
+    }
+}
diff --git a/server/red_channel.h b/server/red_channel.h
index 619a841..1f1538e 100644
--- a/server/red_channel.h
+++ b/server/red_channel.h
@@ -151,6 +151,11 @@ typedef struct PipeItem {
     int type;
 } PipeItem;
 
+static inline int pipe_item_is_linked(PipeItem *item)
+{
+    return ring_item_is_linked(&item->link);
+}
+
 typedef uint8_t *(*channel_alloc_msg_recv_buf_proc)(RedChannelClient *channel,
                                                     uint16_t type, uint32_t size);
 typedef int (*channel_handle_parsed_proc)(RedChannelClient *rcc, uint32_t size, uint16_t type,
@@ -622,5 +627,6 @@ int red_channel_client_wait_outgoing_item(RedChannelClient *rcc,
                                           int64_t timeout);
 int red_channel_wait_all_sent(RedChannel *channel,
                               int64_t timeout);
+void red_channel_client_disconnect_if_pending_send(RedChannelClient *rcc);
 
 #endif
diff --git a/server/red_worker.c b/server/red_worker.c
index acca894..f5cfa7c 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -1398,11 +1398,6 @@ static void show_draw_item(RedWorker *worker, DrawItem *draw_item, const char *p
            draw_item->base.rgn.extents.y2);
 }
 
-static inline int pipe_item_is_linked(PipeItem *item)
-{
-    return ring_item_is_linked(&item->link);
-}
-
 static void red_pipe_add_verb(RedChannelClient* rcc, uint16_t verb)
 {
     VerbItem *item = spice_new(VerbItem, 1);
@@ -11133,15 +11128,6 @@ void handle_dev_destroy_surface_wait(void *opaque, void *payload)
     dev_destroy_surface_wait(worker, msg->surface_id);
 }
 
-static void rcc_disconnect_if_pending_send(RedChannelClient *rcc)
-{
-    if (red_channel_client_blocked(rcc) || rcc->pipe_size > 0) {
-        red_channel_client_disconnect(rcc);
-    } else {
-        spice_assert(red_channel_client_no_item_being_sent(rcc));
-    }
-}
-
 static inline void red_cursor_reset(RedWorker *worker)
 {
     if (worker->cursor) {
@@ -11162,7 +11148,7 @@ static inline void red_cursor_reset(RedWorker *worker)
         if (!red_channel_wait_all_sent(&worker->cursor_channel->common.base,
                                        DISPLAY_CLIENT_TIMEOUT)) {
             red_channel_apply_clients(&worker->cursor_channel->common.base,
-                                      rcc_disconnect_if_pending_send);
+                               red_channel_client_disconnect_if_pending_send);
         }
     }
 }
@@ -11456,12 +11442,12 @@ void handle_dev_stop(void *opaque, void *payload)
     if (!red_channel_wait_all_sent(&worker->display_channel->common.base,
                                    DISPLAY_CLIENT_TIMEOUT)) {
         red_channel_apply_clients(&worker->display_channel->common.base,
-                                  rcc_disconnect_if_pending_send);
+                                 red_channel_client_disconnect_if_pending_send);
     }
     if (!red_channel_wait_all_sent(&worker->cursor_channel->common.base,
                                    DISPLAY_CLIENT_TIMEOUT)) {
         red_channel_apply_clients(&worker->cursor_channel->common.base,
-                                  rcc_disconnect_if_pending_send);
+                                 red_channel_client_disconnect_if_pending_send);
     }
 }
 
commit c61404f102d2a6c5f0fb6e6f7d1c17911c91d053
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Sun Sep 1 18:37:04 2013 +0200

    worker: replace init with red_worker_new
    
    Acked-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

diff --git a/server/red_worker.c b/server/red_worker.c
index 538911d..acca894 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -12099,8 +12099,9 @@ static void handle_dev_input(int fd, int event, void *opaque)
     dispatcher_handle_recv_read(red_dispatcher_get_dispatcher(worker->red_dispatcher));
 }
 
-static void red_init(RedWorker *worker, WorkerInitData *init_data)
+static RedWorker* red_worker_new(WorkerInitData *init_data)
 {
+    RedWorker *worker = spice_new0(RedWorker, 1);
     RedWorkerMessage message;
     Dispatcher *dispatcher;
     int i;
@@ -12108,7 +12109,6 @@ static void red_init(RedWorker *worker, WorkerInitData *init_data)
 
     spice_assert(sizeof(CursorItem) <= QXL_CURSUR_DEVICE_DATA_SIZE);
 
-    memset(worker, 0, sizeof(RedWorker));
     record_filename = getenv("SPICE_WORKER_RECORD_FILENAME");
     if (record_filename) {
         static const char header[] = "SPICE_REPLAY 1\n";
@@ -12193,6 +12193,8 @@ static void red_init(RedWorker *worker, WorkerInitData *init_data)
 #endif
     red_init_zlib(worker);
     worker->event_timeout = INF_EVENT_WAIT;
+
+    return worker;
 }
 
 static void red_display_cc_free_glz_drawables(RedChannelClient *rcc)
@@ -12204,7 +12206,7 @@ static void red_display_cc_free_glz_drawables(RedChannelClient *rcc)
 
 SPICE_GNUC_NORETURN void *red_worker_main(void *arg)
 {
-    RedWorker *worker = spice_malloc(sizeof(RedWorker));
+    RedWorker *worker = red_worker_new(arg);
 
     spice_info("begin");
     spice_assert(MAX_PIPE_SIZE > WIDE_CLIENT_ACK_WINDOW &&
@@ -12214,8 +12216,6 @@ SPICE_GNUC_NORETURN void *red_worker_main(void *arg)
         spice_error("pthread_getcpuclockid failed");
     }
 
-    red_init(worker, (WorkerInitData *)arg);
-
     for (;;) {
         int i, num_events;
         unsigned int timeout;
commit 31a66ae6e78a3e1323c3eeb96fb18907873fd601
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Thu Feb 27 14:59:18 2014 +0200

    red_worker: replace some abort()
    
    Acked-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

diff --git a/server/red_worker.c b/server/red_worker.c
index babb597..538911d 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -12275,5 +12275,6 @@ SPICE_GNUC_NORETURN void *red_worker_main(void *arg)
         }
         red_push(worker);
     }
-    abort();
+
+    spice_warn_if_reached();
 }


More information about the Spice-commits mailing list