[Spice-devel] [RFC v4 53/62] server/red_worker: move free from display_channel_send_item to _release_item
Alon Levy
alevy at redhat.com
Tue Apr 26 03:55:18 PDT 2011
---
server/red_worker.c | 74 ++++++++++++++++++++++++++++++--------------------
1 files changed, 44 insertions(+), 30 deletions(-)
diff --git a/server/red_worker.c b/server/red_worker.c
index 4402570..6ab3d7c 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -8402,86 +8402,70 @@ static void display_channel_send_item(RedChannelClient *rcc, PipeItem *pipe_item
{
SpiceMarshaller *m = red_channel_client_get_marshaller(rcc);
DisplayChannelClient *dcc = RCC_TO_DCC(rcc);
- DisplayChannel *display_channel = DCC_TO_DC(dcc);
- RedWorker *worker = display_channel->common.worker;
- Surfaces *surfaces = dcc->common.surfaces;
+ RedWorker *worker = DCC_TO_WORKER(dcc);
red_display_reset_send_data(dcc);
switch (pipe_item->type) {
case PIPE_ITEM_TYPE_DRAW: {
Drawable *drawable = SPICE_CONTAINEROF(pipe_item, Drawable, pipe_item);
marshall_qxl_drawable(rcc, m, drawable);
- release_drawable(worker, &worker->surfaces, drawable);
+ release_drawable(worker, dcc->common.surfaces, drawable);
break;
}
case PIPE_ITEM_TYPE_INVAL_ONE:
red_marshall_inval(rcc, m, (CacheItem *)pipe_item);
- free(pipe_item);
break;
case PIPE_ITEM_TYPE_STREAM_CREATE: {
StreamAgent *agent = SPICE_CONTAINEROF(pipe_item, StreamAgent, create_item);
red_display_marshall_stream_start(rcc, m, agent);
- red_display_release_stream(surfaces, agent);
break;
}
case PIPE_ITEM_TYPE_STREAM_CLIP: {
StreamClipItem* clip_item = (StreamClipItem *)pipe_item;
red_display_marshall_stream_clip(rcc, m, clip_item);
- red_display_release_stream_clip(surfaces, clip_item);
break;
}
case PIPE_ITEM_TYPE_STREAM_DESTROY: {
StreamAgent *agent = SPICE_CONTAINEROF(pipe_item, StreamAgent, destroy_item);
red_display_marshall_stream_end(rcc, m, agent);
- red_display_release_stream(surfaces, agent);
break;
}
case PIPE_ITEM_TYPE_UPGRADE:
red_display_marshall_upgrade(rcc, m, (UpgradeItem *)pipe_item);
- release_upgrade_item(worker, &worker->surfaces, (UpgradeItem *)pipe_item);
break;
case PIPE_ITEM_TYPE_VERB:
red_marshall_verb(rcc, ((VerbItem*)pipe_item)->verb);
- free(pipe_item);
break;
case PIPE_ITEM_TYPE_MIGRATE:
red_printf("PIPE_ITEM_TYPE_MIGRATE");
display_channel_marshall_migrate(rcc, m);
- free(pipe_item);
break;
case PIPE_ITEM_TYPE_MIGRATE_DATA:
display_channel_marshall_migrate_data(rcc, m);
- free(pipe_item);
break;
case PIPE_ITEM_TYPE_IMAGE:
red_marshall_image(rcc, m, (ImageItem *)pipe_item);
- release_image_item((ImageItem *)pipe_item);
break;
case PIPE_ITEM_TYPE_PIXMAP_SYNC:
display_channel_marshall_pixmap_sync(rcc, m);
- free(pipe_item);
break;
case PIPE_ITEM_TYPE_PIXMAP_RESET:
display_channel_marshall_reset_cache(rcc, m);
- free(pipe_item);
break;
case PIPE_ITEM_TYPE_INVAL_PALLET_CACHE:
red_reset_palette_cache(dcc);
red_marshall_verb(rcc, SPICE_MSG_DISPLAY_INVAL_ALL_PALETTES);
- free(pipe_item);
break;
case PIPE_ITEM_TYPE_CREATE_SURFACE: {
SurfaceCreateItem *surface_create = SPICE_CONTAINEROF(pipe_item, SurfaceCreateItem,
pipe_item);
red_marshall_surface_create(rcc, m, &surface_create->surface_create);
- free(surface_create);
break;
}
case PIPE_ITEM_TYPE_DESTROY_SURFACE: {
SurfaceDestroyItem *surface_destroy = SPICE_CONTAINEROF(pipe_item, SurfaceDestroyItem,
pipe_item);
red_marshall_surface_destroy(rcc, m, surface_destroy->surface_destroy.surface_id);
- free(surface_destroy);
break;
}
default:
@@ -9705,7 +9689,7 @@ static void display_channel_hold_pipe_item(RedChannelClient *rcc, PipeItem *item
}
}
-static void display_channel_release_item(RedChannelClient *rcc, PipeItem *item,
+static void display_channel_release_item(RedChannelClient *rcc, PipeItem *pipe_item,
int item_pushed /* ignored */)
{
RedChannel *channel = rcc->channel;
@@ -9714,25 +9698,55 @@ static void display_channel_release_item(RedChannelClient *rcc, PipeItem *item,
DisplayChannelClient *dcc = RCC_TO_DCC(rcc);
Surfaces *surfaces = dcc->common.surfaces;
- ASSERT(item);
- switch (item->type) {
- case PIPE_ITEM_TYPE_DRAW:
- case PIPE_ITEM_TYPE_STREAM_CREATE:
- release_drawable(common->worker, &common->worker->surfaces,
- SPICE_CONTAINEROF(item, Drawable, pipe_item));
+ ASSERT(pipe_item);
+ switch (pipe_item->type) {
+ case PIPE_ITEM_TYPE_DRAW: {
+ Drawable *drawable = SPICE_CONTAINEROF(pipe_item, Drawable, pipe_item);
+ release_drawable(worker, surfaces, drawable);
break;
+ }
+ case PIPE_ITEM_TYPE_STREAM_CREATE: {
+ StreamAgent *agent = SPICE_CONTAINEROF(pipe_item, StreamAgent, create_item);
+ red_display_release_stream(surfaces, agent);
+ release_drawable(common->worker, surfaces,
+ SPICE_CONTAINEROF(pipe_item, Drawable, pipe_item));
+ break;
+ }
case PIPE_ITEM_TYPE_STREAM_CLIP:
- red_display_release_stream_clip(surfaces, (StreamClipItem *)item);
+ red_display_release_stream_clip(surfaces, (StreamClipItem *)pipe_item);
break;
+ case PIPE_ITEM_TYPE_STREAM_DESTROY: {
+ StreamAgent *agent = SPICE_CONTAINEROF(pipe_item, StreamAgent, destroy_item);
+ red_display_release_stream(surfaces, agent);
+ break;
+ }
case PIPE_ITEM_TYPE_UPGRADE:
- release_upgrade_item(worker, &worker->surfaces, (UpgradeItem *)item);
+ release_upgrade_item(worker, &worker->surfaces, (UpgradeItem *)pipe_item);
+ break;
+ case PIPE_ITEM_TYPE_INVAL_ONE:
+ case PIPE_ITEM_TYPE_VERB:
+ case PIPE_ITEM_TYPE_MIGRATE:
+ case PIPE_ITEM_TYPE_MIGRATE_DATA:
+ case PIPE_ITEM_TYPE_PIXMAP_SYNC:
+ case PIPE_ITEM_TYPE_PIXMAP_RESET:
+ case PIPE_ITEM_TYPE_INVAL_PALLET_CACHE:
+ free(pipe_item);
break;
case PIPE_ITEM_TYPE_IMAGE:
- release_image_item((ImageItem *)item);
+ release_image_item((ImageItem *)pipe_item);
break;
- case PIPE_ITEM_TYPE_VERB:
- free(item);
+ case PIPE_ITEM_TYPE_CREATE_SURFACE: {
+ SurfaceCreateItem *surface_create = SPICE_CONTAINEROF(pipe_item, SurfaceCreateItem,
+ pipe_item);
+ free(surface_create);
break;
+ }
+ case PIPE_ITEM_TYPE_DESTROY_SURFACE: {
+ SurfaceDestroyItem *surface_destroy = SPICE_CONTAINEROF(pipe_item, SurfaceDestroyItem,
+ pipe_item);
+ free(surface_destroy);
+ break;
+ }
default:
PANIC("invalid item type");
}
--
1.7.4.4
More information about the Spice-devel
mailing list