[Spice-devel] [PATCH v2 05/40] server/red_worker: introduce red_channel_pipe_clear

Alon Levy alevy at redhat.com
Wed Mar 2 00:31:28 PST 2011


No more common_release_pipe_item
---
 server/red_worker.c |   77 ++++++++++++---------------------------------------
 1 files changed, 18 insertions(+), 59 deletions(-)

diff --git a/server/red_worker.c b/server/red_worker.c
index d70447b..57d67c1 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -1371,69 +1371,17 @@ static void release_upgrade_item(RedWorker* worker, UpgradeItem *item)
     }
 }
 
-static void common_release_pipe_item(RedChannel *channel, PipeItem *item)
-{
-    CommonChannel *common = SPICE_CONTAINEROF(channel, CommonChannel, base);
-
-    switch (item->type) {
-    case PIPE_ITEM_TYPE_DRAW:
-        release_drawable(common->worker, SPICE_CONTAINEROF(item, Drawable, pipe_item));
-        break;
-    case PIPE_ITEM_TYPE_CURSOR:
-        red_release_cursor(common->worker, (CursorItem *)item);
-        break;
-    case PIPE_ITEM_TYPE_UPGRADE:
-        release_upgrade_item(common->worker, (UpgradeItem *)item);
-        break;
-    case PIPE_ITEM_TYPE_PIXMAP_RESET:
-    case PIPE_ITEM_TYPE_PIXMAP_SYNC:
-    case PIPE_ITEM_TYPE_INVAL_ONE:
-    case PIPE_ITEM_TYPE_MIGRATE:
-    case PIPE_ITEM_TYPE_SET_ACK:
-    case PIPE_ITEM_TYPE_CURSOR_INIT:
-    case PIPE_ITEM_TYPE_VERB:
-    case PIPE_ITEM_TYPE_MIGRATE_DATA:
-    case PIPE_ITEM_TYPE_INVAL_PALLET_CACHE:
-    case PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE:
-        free(item);
-        break;
-    case PIPE_ITEM_TYPE_IMAGE:
-        release_image_item((ImageItem *)item);
-        break;
-    case PIPE_ITEM_TYPE_STREAM_CREATE:
-        red_display_release_stream((DisplayChannel *)channel,
-                                   SPICE_CONTAINEROF(item, StreamAgent, create_item));
-        break;
-    case PIPE_ITEM_TYPE_STREAM_CLIP:
-        red_display_release_stream_clip((DisplayChannel *)channel, (StreamClipItem*)item);
-        break;
-    case PIPE_ITEM_TYPE_STREAM_DESTROY:
-        red_display_release_stream((DisplayChannel *)channel,
-                                   SPICE_CONTAINEROF(item, StreamAgent, destroy_item));
-        break;
-    case PIPE_ITEM_TYPE_CREATE_SURFACE: {
-        SurfaceCreateItem *surface_create = SPICE_CONTAINEROF(item, SurfaceCreateItem,
-                                                              pipe_item);
-        free(surface_create);
-        break;
-    }
-    case PIPE_ITEM_TYPE_DESTROY_SURFACE: {
-        SurfaceDestroyItem *surface_destroy = SPICE_CONTAINEROF(item, SurfaceDestroyItem,
-                                                                pipe_item);
-        free(surface_destroy);
-        break;
-    }
-    }
-}
-
-static void red_pipe_clear(RedChannel *channel)
+static void red_channel_pipe_clear(RedChannel *channel)
 {
     PipeItem *item;
 
     ASSERT(channel);
+    if (channel->send_data.item) {
+        channel->release_item(channel, channel->send_data.item, TRUE);
+    }
     while ((item = (PipeItem *)ring_get_head(&channel->pipe))) {
         ring_remove(&item->link);
-        common_release_pipe_item(channel, item);
+        channel->release_item(channel, item, FALSE);
     }
     channel->pipe_size = 0;
 }
@@ -8558,7 +8506,7 @@ static inline int red_channel_is_connected(RedChannel *channel)
 static void red_disconnect_channel(RedChannel *channel)
 {
     channel_release_res(channel);
-    red_pipe_clear(channel);
+    red_channel_pipe_clear(channel);
     reds_stream_free(channel->stream);
     channel->stream = NULL;
     channel->send_data.blocked = FALSE;
@@ -9492,6 +9440,8 @@ static void display_channel_release_item(RedChannel *channel, PipeItem *item, in
     case PIPE_ITEM_TYPE_IMAGE:
         release_image_item((ImageItem *)item);
         break;
+    case PIPE_ITEM_TYPE_SET_ACK:
+        break;
     default:
         PANIC("invalid item type");
     }
@@ -9622,7 +9572,16 @@ static void cursor_channel_release_item(RedChannel *channel, PipeItem *item, int
     CommonChannel *common = SPICE_CONTAINEROF(channel, CommonChannel, base);
 
     ASSERT(item);
-    red_release_cursor(common->worker, SPICE_CONTAINEROF(item, CursorItem, pipe_data));
+    switch (item->type) {
+        case PIPE_ITEM_TYPE_CURSOR:
+            red_release_cursor(common->worker, SPICE_CONTAINEROF(item, CursorItem, pipe_data));
+            break;
+        case PIPE_ITEM_TYPE_SET_ACK:
+            free(item);
+            break;
+        default:
+            PANIC("invalid item type");
+    }
 }
 
 static void red_connect_cursor(RedWorker *worker, RedsStream *stream, int migrate)
-- 
1.7.4.1



More information about the Spice-devel mailing list