[PATCH v2 9/9] Remove third argument from red_channel_client_init_send_data()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This third argument (and the 'item' member of
RedChannelClient::priv::send_data) was a somewhat roundabout way to keep
the RedPipeItem alive until a message is sent, just in case some data
owned by that pipeitem was added to the marshaller by reference. This
was a rather confusing mechanism, however, since it did not have any
obvious connection to the _add_by_ref() call. It was never very clear
whether you needed to pass an item to this function or not. The previous
series of patches made this parameter unnecessary since the referencing
of the pipe item (or other related structure) is now more explicitly
connected to the calls to spice_marshaller_add_by_ref_full().
---
 server/cursor-channel.c             | 14 ++++----
 server/dcc-send.c                   | 68 ++++++++++++++++++-------------------
 server/inputs-channel-client.c      |  2 +-
 server/inputs-channel.c             |  6 ++--
 server/main-channel-client.c        | 32 ++++++++---------
 server/red-channel-client-private.h |  1 -
 server/red-channel-client.c         | 27 +++------------
 server/red-channel-client.h         |  2 +-
 server/smartcard-channel-client.c   |  2 +-
 server/smartcard.c                  |  2 +-
 server/spicevmc.c                   | 10 +++---
 11 files changed, 74 insertions(+), 92 deletions(-)

diff --git a/server/cursor-channel.c b/server/cursor-channel.c
index 8befa6e..f60124f 100644
--- a/server/cursor-channel.c
+++ b/server/cursor-channel.c
@@ -211,7 +211,7 @@ static void red_marshall_cursor_init(CursorChannelClient *ccc, SpiceMarshaller *
     spice_assert(rcc);
     cursor_channel = CURSOR_CHANNEL(red_channel_client_get_channel(rcc));
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_CURSOR_INIT, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_CURSOR_INIT);
     msg.visible = cursor_channel->cursor_visible;
     msg.position = cursor_channel->cursor_position;
     msg.trail_length = cursor_channel->cursor_trail_length;
@@ -238,7 +238,7 @@ static void cursor_marshall(CursorChannelClient *ccc,
     case QXL_CURSOR_MOVE:
         {
             SpiceMsgCursorMove cursor_move;
-            red_channel_client_init_send_data(rcc, SPICE_MSG_CURSOR_MOVE, NULL);
+            red_channel_client_init_send_data(rcc, SPICE_MSG_CURSOR_MOVE);
             cursor_move.position = cmd->u.position;
             spice_marshall_msg_cursor_move(m, &cursor_move);
             break;
@@ -248,7 +248,7 @@ static void cursor_marshall(CursorChannelClient *ccc,
             SpiceMsgCursorSet cursor_set;
             AddBufInfo info;
 
-            red_channel_client_init_send_data(rcc, SPICE_MSG_CURSOR_SET, NULL);
+            red_channel_client_init_send_data(rcc, SPICE_MSG_CURSOR_SET);
             cursor_set.position = cmd->u.set.position;
             cursor_set.visible = cursor_channel->cursor_visible;
 
@@ -258,13 +258,13 @@ static void cursor_marshall(CursorChannelClient *ccc,
             break;
         }
     case QXL_CURSOR_HIDE:
-        red_channel_client_init_send_data(rcc, SPICE_MSG_CURSOR_HIDE, NULL);
+        red_channel_client_init_send_data(rcc, SPICE_MSG_CURSOR_HIDE);
         break;
     case QXL_CURSOR_TRAIL:
         {
             SpiceMsgCursorTrail cursor_trail;
 
-            red_channel_client_init_send_data(rcc, SPICE_MSG_CURSOR_TRAIL, NULL);
+            red_channel_client_init_send_data(rcc, SPICE_MSG_CURSOR_TRAIL);
             cursor_trail.length = cmd->u.trail.length;
             cursor_trail.frequency = cmd->u.trail.frequency;
             spice_marshall_msg_cursor_trail(m, &cursor_trail);
@@ -281,7 +281,7 @@ static inline void red_marshall_inval(RedChannelClient *rcc,
 {
     SpiceMsgDisplayInvalOne inval_one;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_CURSOR_INVAL_ONE, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_CURSOR_INVAL_ONE);
     inval_one.id = cach_item->id;
 
     spice_marshall_msg_cursor_inval_one(base_marshaller, &inval_one);
@@ -305,7 +305,7 @@ static void cursor_channel_send_item(RedChannelClient *rcc, RedPipeItem *pipe_it
         break;
     case RED_PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE:
         cursor_channel_client_reset_cursor_cache(rcc);
-        red_channel_client_init_send_data(rcc, SPICE_MSG_CURSOR_INVAL_ALL, NULL);
+        red_channel_client_init_send_data(rcc, SPICE_MSG_CURSOR_INVAL_ALL);
         break;
     default:
         spice_error("invalid pipe item type");
diff --git a/server/dcc-send.c b/server/dcc-send.c
index 09a2bb4..b9260ed 100644
--- a/server/dcc-send.c
+++ b/server/dcc-send.c
@@ -285,12 +285,12 @@ static void send_free_list(RedChannelClient *rcc)
 
     if (!free_list->wait.header.wait_count) {
         /* only one message, no need for a list */
-        red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_INVAL_LIST, NULL);
+        red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_INVAL_LIST);
         spice_marshall_msg_display_inval_list(urgent_marshaller, free_list->res);
         return;
     }
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_LIST, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_LIST);
 
     /* append invalidate list */
     inval_m = spice_marshaller_get_submarshaller(urgent_marshaller);
@@ -554,7 +554,7 @@ static void marshall_qxl_draw_fill(RedChannelClient *rcc,
     SpiceMarshaller *mask_bitmap_out;
     SpiceFill fill;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_FILL, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_FILL);
     fill_base(base_marshaller, item);
     fill = drawable->u.fill;
     spice_marshall_Fill(base_marshaller,
@@ -898,7 +898,7 @@ static FillBitsType red_marshall_qxl_draw_opaque(RedChannelClient *rcc,
     SpiceOpaque opaque;
     FillBitsType src_send_type;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_OPAQUE, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_OPAQUE);
     fill_base(base_marshaller, item);
     opaque = drawable->u.opaque;
     spice_marshall_Opaque(base_marshaller,
@@ -995,7 +995,7 @@ static FillBitsType red_marshall_qxl_draw_copy(RedChannelClient *rcc,
     SpiceCopy copy;
     FillBitsType src_send_type;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_COPY, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_COPY);
     fill_base(base_marshaller, item);
     copy = drawable->u.copy;
     spice_marshall_Copy(base_marshaller,
@@ -1044,7 +1044,7 @@ static void red_marshall_qxl_draw_transparent(RedChannelClient *rcc,
     SpiceMarshaller *src_bitmap_out;
     SpiceTransparent transparent;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_TRANSPARENT, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_TRANSPARENT);
     fill_base(base_marshaller, item);
     transparent = drawable->u.transparent;
     spice_marshall_Transparent(base_marshaller,
@@ -1092,7 +1092,7 @@ static FillBitsType red_marshall_qxl_draw_alpha_blend(RedChannelClient *rcc,
     SpiceAlphaBlend alpha_blend;
     FillBitsType src_send_type;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_ALPHA_BLEND, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_ALPHA_BLEND);
     fill_base(base_marshaller, item);
     alpha_blend = drawable->u.alpha_blend;
     spice_marshall_AlphaBlend(base_marshaller,
@@ -1139,7 +1139,7 @@ static void red_marshall_qxl_copy_bits(RedChannelClient *rcc,
     RedDrawable *drawable = item->red_drawable;
     SpicePoint copy_bits;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_COPY_BITS, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_COPY_BITS);
     fill_base(base_marshaller, item);
     copy_bits = drawable->u.copy_bits.src_pos;
     spice_marshall_Point(base_marshaller,
@@ -1186,7 +1186,7 @@ static void red_marshall_qxl_draw_blend(RedChannelClient *rcc,
     SpiceMarshaller *mask_bitmap_out;
     SpiceBlend blend;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_BLEND, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_BLEND);
     fill_base(base_marshaller, item);
     blend = drawable->u.blend;
     spice_marshall_Blend(base_marshaller,
@@ -1250,7 +1250,7 @@ static void red_marshall_qxl_draw_blackness(RedChannelClient *rcc,
     SpiceMarshaller *mask_bitmap_out;
     SpiceBlackness blackness;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_BLACKNESS, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_BLACKNESS);
     fill_base(base_marshaller, item);
     blackness = drawable->u.blackness;
 
@@ -1284,7 +1284,7 @@ static void red_marshall_qxl_draw_whiteness(RedChannelClient *rcc,
     SpiceMarshaller *mask_bitmap_out;
     SpiceWhiteness whiteness;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_WHITENESS, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_WHITENESS);
     fill_base(base_marshaller, item);
     whiteness = drawable->u.whiteness;
 
@@ -1317,7 +1317,7 @@ static void red_marshall_qxl_draw_inverse(RedChannelClient *rcc,
     SpiceMarshaller *mask_bitmap_out;
     SpiceInvers inverse;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_INVERS, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_INVERS);
     fill_base(base_marshaller, item);
     inverse = drawable->u.invers;
 
@@ -1347,7 +1347,7 @@ static void red_marshall_qxl_draw_rop3(RedChannelClient *rcc,
     SpiceMarshaller *brush_pat_out;
     SpiceMarshaller *mask_bitmap_out;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_ROP3, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_ROP3);
     fill_base(base_marshaller, item);
     rop3 = drawable->u.rop3;
     spice_marshall_Rop3(base_marshaller,
@@ -1430,7 +1430,7 @@ static void red_marshall_qxl_draw_composite(RedChannelClient *rcc,
     SpiceMarshaller *mask_bitmap_out;
     SpiceComposite composite;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_COMPOSITE, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_COMPOSITE);
     fill_base(base_marshaller, item);
     composite = drawable->u.composite;
     spice_marshall_Composite(base_marshaller,
@@ -1511,7 +1511,7 @@ static void red_marshall_qxl_draw_stroke(RedChannelClient *rcc,
     SpiceMarshaller *brush_pat_out;
     SpiceMarshaller *style_out;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_STROKE, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_STROKE);
     fill_base(base_marshaller, item);
     stroke = drawable->u.stroke;
     spice_marshall_Stroke(base_marshaller,
@@ -1591,7 +1591,7 @@ static void red_marshall_qxl_draw_text(RedChannelClient *rcc,
     SpiceMarshaller *brush_pat_out;
     SpiceMarshaller *back_brush_pat_out;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_TEXT, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_TEXT);
     fill_base(base_marshaller, item);
     text = drawable->u.text;
     spice_marshall_Text(base_marshaller,
@@ -1739,7 +1739,7 @@ static int red_marshall_stream_data(RedChannelClient *rcc,
     if (!is_sized) {
         SpiceMsgDisplayStreamData stream_data;
 
-        red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_STREAM_DATA, NULL);
+        red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_STREAM_DATA);
 
         stream_data.base.id = display_channel_get_stream_id(display, stream);
         stream_data.base.multi_media_time = frame_mm_time;
@@ -1749,7 +1749,7 @@ static int red_marshall_stream_data(RedChannelClient *rcc,
     } else {
         SpiceMsgDisplayStreamDataSized stream_data;
 
-        red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_STREAM_DATA_SIZED, NULL);
+        red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_STREAM_DATA_SIZED);
 
         stream_data.base.id = display_channel_get_stream_id(display, stream);
         stream_data.base.multi_media_time = frame_mm_time;
@@ -1779,7 +1779,7 @@ static inline void marshall_inval_palette(RedChannelClient *rcc,
 {
     SpiceMsgDisplayInvalOne inval_one;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_INVAL_PALETTE, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_INVAL_PALETTE);
     inval_one.id = cache_item->id;
 
     spice_marshall_msg_display_inval_palette(base_marshaller, &inval_one);
@@ -1826,7 +1826,7 @@ static void display_channel_marshall_migrate_data(RedChannelClient *rcc,
 
     display_channel = DISPLAY_CHANNEL(red_channel_client_get_channel(rcc));
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_MIGRATE_DATA, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_MIGRATE_DATA);
     spice_marshaller_add_uint32(base_marshaller, SPICE_MIGRATE_DATA_DISPLAY_MAGIC);
     spice_marshaller_add_uint32(base_marshaller, SPICE_MIGRATE_DATA_DISPLAY_VERSION);
 
@@ -1860,7 +1860,7 @@ static void display_channel_marshall_pixmap_sync(RedChannelClient *rcc,
     SpiceMsgWaitForChannels wait;
     PixmapCache *pixmap_cache;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_WAIT_FOR_CHANNELS, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_WAIT_FOR_CHANNELS);
     pixmap_cache = dcc->priv->pixmap_cache;
 
     pthread_mutex_lock(&pixmap_cache->lock);
@@ -1911,7 +1911,7 @@ static void display_channel_marshall_reset_cache(RedChannelClient *rcc,
     DisplayChannelClient *dcc = DISPLAY_CHANNEL_CLIENT(rcc);
     SpiceMsgWaitForChannels wait;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_INVAL_ALL_PIXMAPS, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_INVAL_ALL_PIXMAPS);
     dcc_pixmap_cache_reset(dcc, &wait);
 
     spice_marshall_msg_display_inval_all_pixmaps(base_marshaller,
@@ -1960,7 +1960,7 @@ static void red_marshall_image(RedChannelClient *rcc,
     chunks = spice_chunks_new_linear(item->data, bitmap.stride * bitmap.y);
     bitmap.data = chunks;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_COPY, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_COPY);
 
     copy.base.surface_id = item->surface_id;
     copy.base.box.left = item->pos.x;
@@ -2160,7 +2160,7 @@ static void marshall_stream_start(RedChannelClient *rcc,
         /* Without a video encoder nothing will be streamed */
         return;
     }
-    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_STREAM_CREATE, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_STREAM_CREATE);
     SpiceMsgDisplayStreamCreate stream_create;
     SpiceClipRects clip_rects;
 
@@ -2198,7 +2198,7 @@ static void marshall_stream_clip(RedChannelClient *rcc,
 
     spice_return_if_fail(agent->stream);
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_STREAM_CLIP, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_STREAM_CLIP);
     SpiceMsgDisplayStreamClip stream_clip;
 
     stream_clip.id = display_channel_get_stream_id(DCC_TO_DC(dcc), agent->stream);
@@ -2214,7 +2214,7 @@ static void marshall_stream_end(RedChannelClient *rcc,
     DisplayChannelClient *dcc = DISPLAY_CHANNEL_CLIENT(rcc);
     SpiceMsgDisplayStreamDestroy destroy;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_STREAM_DESTROY, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_STREAM_DESTROY);
     destroy.id = display_channel_get_stream_id(DCC_TO_DC(dcc), agent->stream);
     stream_agent_stop(agent);
     spice_marshall_msg_display_stream_destroy(base_marshaller, &destroy);
@@ -2230,7 +2230,7 @@ static void marshall_upgrade(RedChannelClient *rcc, SpiceMarshaller *m,
     SpiceMarshaller *src_bitmap_out, *mask_bitmap_out;
 
     spice_assert(channel && item && item->drawable);
-    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_COPY, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_COPY);
 
     red_drawable = item->drawable->red_drawable;
     spice_assert(red_drawable->type == QXL_DRAW_COPY);
@@ -2256,7 +2256,7 @@ static void marshall_surface_create(RedChannelClient *rcc,
     DisplayChannelClient *dcc = DISPLAY_CHANNEL_CLIENT(rcc);
 
     region_init(&dcc->priv->surface_client_lossy_region[surface_create->surface_id]);
-    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_SURFACE_CREATE, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_SURFACE_CREATE);
 
     spice_marshall_msg_display_surface_create(base_marshaller, surface_create);
 }
@@ -2268,7 +2268,7 @@ static void marshall_surface_destroy(RedChannelClient *rcc,
     SpiceMsgSurfaceDestroy surface_destroy;
 
     region_destroy(&dcc->priv->surface_client_lossy_region[surface_id]);
-    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_SURFACE_DESTROY, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_SURFACE_DESTROY);
 
     surface_destroy.surface_id = surface_id;
 
@@ -2283,7 +2283,7 @@ static void marshall_monitors_config(RedChannelClient *rcc, SpiceMarshaller *bas
     SpiceMsgDisplayMonitorsConfig *msg = spice_malloc0(sizeof(*msg) + heads_size);
     int count = 0; // ignore monitors_config->count, it may contain zero width monitors, remove them now
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_MONITORS_CONFIG, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_MONITORS_CONFIG);
     for (i = 0 ; i < monitors_config->count; ++i) {
         if (monitors_config->heads[i].width == 0 || monitors_config->heads[i].height == 0) {
             continue;
@@ -2310,7 +2310,7 @@ static void marshall_stream_activate_report(RedChannelClient *rcc,
     StreamAgent *agent = &dcc->priv->stream_agents[stream_id];
     SpiceMsgDisplayStreamActivateReport msg;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_STREAM_ACTIVATE_REPORT, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_STREAM_ACTIVATE_REPORT);
     msg.stream_id = stream_id;
     msg.unique_id = agent->report_id;
     msg.max_window_size = RED_STREAM_CLIENT_REPORT_WINDOW;
@@ -2328,7 +2328,7 @@ static void marshall_gl_scanout(RedChannelClient *rcc,
 
     SpiceMsgDisplayGlScanoutUnix *scanout = red_qxl_get_gl_scanout(qxl);
     if (scanout != NULL) {
-        red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_GL_SCANOUT_UNIX, NULL);
+        red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_GL_SCANOUT_UNIX);
         spice_marshall_msg_display_gl_scanout_unix(m, scanout);
     }
     red_qxl_put_gl_scanout(qxl, scanout);
@@ -2340,7 +2340,7 @@ static void marshall_gl_draw(RedChannelClient *rcc,
 {
     RedGlDrawItem *p = SPICE_UPCAST(RedGlDrawItem, item);
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_GL_DRAW, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_GL_DRAW);
     spice_marshall_msg_display_gl_draw(m, &p->draw);
 }
 
@@ -2425,7 +2425,7 @@ void dcc_send_item(RedChannelClient *rcc, RedPipeItem *pipe_item)
         break;
     case RED_PIPE_ITEM_TYPE_INVAL_PALETTE_CACHE:
         dcc_palette_cache_reset(dcc);
-        red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_INVAL_ALL_PALETTES, NULL);
+        red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_INVAL_ALL_PALETTES);
         break;
     case RED_PIPE_ITEM_TYPE_CREATE_SURFACE: {
         RedSurfaceCreateItem *surface_create = SPICE_CONTAINEROF(pipe_item, RedSurfaceCreateItem,
diff --git a/server/inputs-channel-client.c b/server/inputs-channel-client.c
index 0200ecd..4a534e8 100644
--- a/server/inputs-channel-client.c
+++ b/server/inputs-channel-client.c
@@ -89,7 +89,7 @@ void inputs_channel_client_send_migrate_data(RedChannelClient *rcc,
 {
     InputsChannelClient *icc = INPUTS_CHANNEL_CLIENT(rcc);
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_MIGRATE_DATA, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_MIGRATE_DATA);
 
     spice_marshaller_add_uint32(m, SPICE_MIGRATE_DATA_INPUTS_MAGIC);
     spice_marshaller_add_uint32(m, SPICE_MIGRATE_DATA_INPUTS_VERSION);
diff --git a/server/inputs-channel.c b/server/inputs-channel.c
index c069b34..fd29425 100644
--- a/server/inputs-channel.c
+++ b/server/inputs-channel.c
@@ -249,7 +249,7 @@ static void inputs_channel_send_item(RedChannelClient *rcc, RedPipeItem *base)
         {
             SpiceMsgInputsKeyModifiers key_modifiers;
 
-            red_channel_client_init_send_data(rcc, SPICE_MSG_INPUTS_KEY_MODIFIERS, NULL);
+            red_channel_client_init_send_data(rcc, SPICE_MSG_INPUTS_KEY_MODIFIERS);
             key_modifiers.modifiers =
                 SPICE_UPCAST(RedKeyModifiersPipeItem, base)->modifiers;
             spice_marshall_msg_inputs_key_modifiers(m, &key_modifiers);
@@ -259,14 +259,14 @@ static void inputs_channel_send_item(RedChannelClient *rcc, RedPipeItem *base)
         {
             SpiceMsgInputsInit inputs_init;
 
-            red_channel_client_init_send_data(rcc, SPICE_MSG_INPUTS_INIT, NULL);
+            red_channel_client_init_send_data(rcc, SPICE_MSG_INPUTS_INIT);
             inputs_init.keyboard_modifiers =
                 SPICE_UPCAST(RedInputsInitPipeItem, base)->modifiers;
             spice_marshall_msg_inputs_init(m, &inputs_init);
             break;
         }
         case RED_PIPE_ITEM_MOUSE_MOTION_ACK:
-            red_channel_client_init_send_data(rcc, SPICE_MSG_INPUTS_MOUSE_MOTION_ACK, NULL);
+            red_channel_client_init_send_data(rcc, SPICE_MSG_INPUTS_MOUSE_MOTION_ACK);
             break;
         case RED_PIPE_ITEM_MIGRATE_DATA:
             INPUTS_CHANNEL(red_channel_client_get_channel(rcc))->src_during_migrate = FALSE;
diff --git a/server/main-channel-client.c b/server/main-channel-client.c
index 4a64a40..fbec09a 100644
--- a/server/main-channel-client.c
+++ b/server/main-channel-client.c
@@ -771,7 +771,7 @@ static void main_channel_marshall_channels(RedChannelClient *rcc,
     SpiceMsgChannels* channels_info;
     RedChannel *channel = red_channel_client_get_channel(rcc);
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_CHANNELS_LIST, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_CHANNELS_LIST);
     channels_info = reds_msg_channels_new(red_channel_get_server(channel));
     spice_marshall_msg_main_channels_list(m, channels_info);
     free(channels_info);
@@ -785,7 +785,7 @@ static void main_channel_marshall_ping(RedChannelClient *rcc,
     SpiceMsgPing ping;
     int size_left = item->size;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_PING, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_PING);
     ping.id = main_channel_client_next_ping_id(mcc);
     ping.timestamp = g_get_monotonic_time();
     spice_marshall_msg_ping(m, &ping);
@@ -803,7 +803,7 @@ static void main_channel_marshall_mouse_mode(RedChannelClient *rcc,
 {
     SpiceMsgMainMouseMode mouse_mode;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_MOUSE_MODE, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_MOUSE_MODE);
     mouse_mode.supported_modes = SPICE_MOUSE_MODE_SERVER;
     if (item->is_client_mouse_allowed) {
         mouse_mode.supported_modes |= SPICE_MOUSE_MODE_CLIENT;
@@ -818,7 +818,7 @@ static void main_channel_marshall_agent_disconnected(RedChannelClient *rcc,
 {
     SpiceMsgMainAgentDisconnect disconnect;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_AGENT_DISCONNECTED, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_AGENT_DISCONNECTED);
     disconnect.error_code = SPICE_LINK_ERR_OK;
     spice_marshall_msg_main_agent_disconnected(m, &disconnect);
 }
@@ -828,7 +828,7 @@ static void main_channel_marshall_tokens(RedChannelClient *rcc,
 {
     SpiceMsgMainAgentTokens tokens;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_AGENT_TOKEN, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_AGENT_TOKEN);
     tokens.num_tokens = item->tokens;
     spice_marshall_msg_main_agent_token(m, &tokens);
 }
@@ -843,7 +843,7 @@ static void main_channel_marshall_agent_data(RedChannelClient *rcc,
                                              SpiceMarshaller *m,
                                              RedAgentDataPipeItem *item)
 {
-    red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_AGENT_DATA, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_AGENT_DATA);
     /* since pipe item owns the data, keep it alive until it's sent */
     red_pipe_item_ref(&item->base);
     spice_marshaller_add_by_ref_full(m, item->data, item->len, marshaller_free_pipe_item, item);
@@ -854,7 +854,7 @@ static void main_channel_marshall_migrate_data_item(RedChannelClient *rcc,
                                                     RedPipeItem *item)
 {
     RedChannel *channel = red_channel_client_get_channel(rcc);
-    red_channel_client_init_send_data(rcc, SPICE_MSG_MIGRATE_DATA, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_MIGRATE_DATA);
     // TODO: from reds split. ugly separation.
     reds_marshall_migrate_data(red_channel_get_server(channel), m);
 }
@@ -866,7 +866,7 @@ static void main_channel_marshall_init(RedChannelClient *rcc,
     SpiceMsgMainInit init; // TODO - remove this copy, make RedInitPipeItem reuse SpiceMsgMainInit
     RedChannel *channel = red_channel_client_get_channel(rcc);
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_INIT, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_INIT);
     init.session_id = item->connection_id;
     init.display_channels_hint = item->display_channels_hint;
     init.current_mouse_mode = item->current_mouse_mode;
@@ -886,7 +886,7 @@ static void main_channel_marshall_notify(RedChannelClient *rcc,
 {
     SpiceMsgNotify notify;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_NOTIFY, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_NOTIFY);
     notify.time_stamp = spice_get_monotonic_time_ns(); // TODO - move to main_new_notify_item
     notify.severity = SPICE_NOTIFY_SEVERITY_WARN;
     notify.visibilty = SPICE_NOTIFY_VISIBILITY_HIGH;
@@ -919,7 +919,7 @@ static void main_channel_marshall_migrate_begin(SpiceMarshaller *m, RedChannelCl
     RedChannel *channel = red_channel_client_get_channel(rcc);
     SpiceMsgMainMigrationBegin migrate;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_MIGRATE_BEGIN, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_MIGRATE_BEGIN);
     main_channel_fill_migrate_dst_info(MAIN_CHANNEL(channel), &migrate.dst_info);
     spice_marshall_msg_main_migrate_begin(m, &migrate);
 }
@@ -931,7 +931,7 @@ static void main_channel_marshall_migrate_begin_seamless(SpiceMarshaller *m,
     RedChannel *channel = red_channel_client_get_channel(rcc);
     SpiceMsgMainMigrateBeginSeamless migrate_seamless;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_MIGRATE_BEGIN_SEAMLESS, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_MIGRATE_BEGIN_SEAMLESS);
     main_channel_fill_migrate_dst_info(MAIN_CHANNEL(channel), &migrate_seamless.dst_info);
     migrate_seamless.src_mig_version = SPICE_MIGRATION_PROTOCOL_VERSION;
     spice_marshall_msg_main_migrate_begin_seamless(m, &migrate_seamless);
@@ -943,7 +943,7 @@ static void main_channel_marshall_multi_media_time(RedChannelClient *rcc,
 {
     SpiceMsgMainMultiMediaTime time_mes;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_MULTI_MEDIA_TIME, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_MULTI_MEDIA_TIME);
     time_mes.time = item->time;
     spice_marshall_msg_main_multi_media_time(m, &time_mes);
 }
@@ -957,7 +957,7 @@ static void main_channel_marshall_migrate_switch(SpiceMarshaller *m, RedChannelC
     const RedsMigSpice *mig_target;
 
     spice_printerr("");
-    red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_MIGRATE_SWITCH_HOST, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_MIGRATE_SWITCH_HOST);
     main_ch = MAIN_CHANNEL(channel);
     mig_target = main_channel_get_migration_target(main_ch);
     migrate.port = mig_target->port;
@@ -980,7 +980,7 @@ static void main_channel_marshall_agent_connected(SpiceMarshaller *m,
 {
     SpiceMsgMainAgentConnectedTokens connected;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_AGENT_CONNECTED_TOKENS, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_AGENT_CONNECTED_TOKENS);
     connected.num_tokens = REDS_AGENT_WINDOW_SIZE;
     spice_marshall_msg_main_agent_connected_tokens(m, &connected);
 }
@@ -1051,11 +1051,11 @@ void main_channel_client_send_item(RedChannelClient *rcc, RedPipeItem *base)
             main_channel_marshall_migrate_switch(m, rcc, base);
             break;
         case RED_PIPE_ITEM_TYPE_MAIN_NAME:
-            red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_NAME, NULL);
+            red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_NAME);
             spice_marshall_msg_main_name(m, &SPICE_UPCAST(RedNamePipeItem, base)->msg);
             break;
         case RED_PIPE_ITEM_TYPE_MAIN_UUID:
-            red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_UUID, NULL);
+            red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_UUID);
             spice_marshall_msg_main_uuid(m, &SPICE_UPCAST(RedUuidPipeItem, base)->msg);
             break;
         case RED_PIPE_ITEM_TYPE_MAIN_AGENT_CONNECTED_TOKENS:
diff --git a/server/red-channel-client-private.h b/server/red-channel-client-private.h
index 0cb3ddd..76c9574 100644
--- a/server/red-channel-client-private.h
+++ b/server/red-channel-client-private.h
@@ -69,7 +69,6 @@ struct RedChannelClientPrivate
         SpiceMarshaller *marshaller;
         SpiceDataHeaderOpaque header;
         uint32_t size;
-        RedPipeItem *item;
         int blocked;
         uint64_t last_sent_serial;
 
diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index 24b2fb0..23c9ad4 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -443,7 +443,7 @@ static void red_channel_client_send_set_ack(RedChannelClient *rcc)
     SpiceMsgSetAck ack;
 
     spice_assert(rcc);
-    red_channel_client_init_send_data(rcc, SPICE_MSG_SET_ACK, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_SET_ACK);
     ack.generation = ++rcc->priv->ack_data.generation;
     ack.window = rcc->priv->ack_data.client_window;
     rcc->priv->ack_data.messages_window = 0;
@@ -457,7 +457,7 @@ static void red_channel_client_send_migrate(RedChannelClient *rcc)
 {
     SpiceMsgMigrate migrate;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_MIGRATE, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_MIGRATE);
     g_object_get(rcc->priv->channel, "migration-flags", &migrate.flags, NULL);
     spice_marshall_msg_migrate(rcc->priv->send_data.marshaller, &migrate);
     if (migrate.flags & SPICE_MIGRATE_NEED_FLUSH) {
@@ -499,7 +499,7 @@ static void red_channel_client_send_ping(RedChannelClient *rcc)
         }
     }
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_PING, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_PING);
     ping.id = rcc->priv->latency_monitor.id;
     ping.timestamp = spice_get_monotonic_time_ns();
     spice_marshall_msg_ping(rcc->priv->send_data.marshaller, &ping);
@@ -510,7 +510,7 @@ static void red_channel_client_send_empty_msg(RedChannelClient *rcc, RedPipeItem
 {
     RedEmptyMsgPipeItem *msg_pipe_item = SPICE_UPCAST(RedEmptyMsgPipeItem, base);
 
-    red_channel_client_init_send_data(rcc, msg_pipe_item->msg, NULL);
+    red_channel_client_init_send_data(rcc, msg_pipe_item->msg);
     red_channel_client_begin_send_message(rcc);
 }
 
@@ -540,20 +540,11 @@ static void red_channel_client_send_item(RedChannelClient *rcc, RedPipeItem *ite
     red_pipe_item_unref(item);
 }
 
-static inline void red_channel_client_release_sent_item(RedChannelClient *rcc)
-{
-    if (rcc->priv->send_data.item) {
-        red_pipe_item_unref(rcc->priv->send_data.item);
-        rcc->priv->send_data.item = NULL;
-    }
-}
-
 static void red_channel_client_restore_main_sender(RedChannelClient *rcc)
 {
     spice_marshaller_reset(rcc->priv->send_data.urgent.marshaller);
     rcc->priv->send_data.marshaller = rcc->priv->send_data.main.marshaller;
     rcc->priv->send_data.header.data = rcc->priv->send_data.main.header_data;
-    rcc->priv->send_data.item = rcc->priv->send_data.main.item;
 }
 
 void red_channel_client_on_out_msg_done(void *opaque)
@@ -575,7 +566,6 @@ void red_channel_client_on_out_msg_done(void *opaque)
             close(fd);
     }
 
-    red_channel_client_release_sent_item(rcc);
     if (rcc->priv->send_data.blocked) {
         SpiceCoreInterfaceInternal *core = red_channel_get_core_interface(rcc->priv->channel);
         rcc->priv->send_data.blocked = FALSE;
@@ -1393,15 +1383,11 @@ int red_channel_client_handle_message(RedChannelClient *rcc, uint32_t size,
     return TRUE;
 }
 
-void red_channel_client_init_send_data(RedChannelClient *rcc, uint16_t msg_type, RedPipeItem *item)
+void red_channel_client_init_send_data(RedChannelClient *rcc, uint16_t msg_type)
 {
     spice_assert(red_channel_client_no_item_being_sent(rcc));
     spice_assert(msg_type != 0);
     rcc->priv->send_data.header.set_msg_type(&rcc->priv->send_data.header, msg_type);
-    rcc->priv->send_data.item = item;
-    if (item) {
-        red_pipe_item_ref(item);
-    }
 }
 
 void red_channel_client_begin_send_message(RedChannelClient *rcc)
@@ -1434,10 +1420,8 @@ SpiceMarshaller *red_channel_client_switch_to_urgent_sender(RedChannelClient *rc
     spice_assert(red_channel_client_no_item_being_sent(rcc));
     spice_assert(rcc->priv->send_data.header.data != NULL);
     rcc->priv->send_data.main.header_data = rcc->priv->send_data.header.data;
-    rcc->priv->send_data.main.item = rcc->priv->send_data.item;
 
     rcc->priv->send_data.marshaller = rcc->priv->send_data.urgent.marshaller;
-    rcc->priv->send_data.item = NULL;
     red_channel_client_reset_send_data(rcc);
     return rcc->priv->send_data.marshaller;
 }
@@ -1589,7 +1573,6 @@ gboolean red_channel_client_is_connected(RedChannelClient *rcc)
 
 static void red_channel_client_clear_sent_item(RedChannelClient *rcc)
 {
-    red_channel_client_release_sent_item(rcc);
     rcc->priv->send_data.blocked = FALSE;
     rcc->priv->send_data.size = 0;
 }
diff --git a/server/red-channel-client.h b/server/red-channel-client.h
index 94b4f58..0d404d1 100644
--- a/server/red-channel-client.h
+++ b/server/red-channel-client.h
@@ -89,7 +89,7 @@ void red_channel_client_shutdown(RedChannelClient *rcc);
 int red_channel_client_handle_message(RedChannelClient *rcc, uint32_t size,
                                       uint16_t type, void *message);
 /* when preparing send_data: should call init and then use marshaller */
-void red_channel_client_init_send_data(RedChannelClient *rcc, uint16_t msg_type, RedPipeItem *item);
+void red_channel_client_init_send_data(RedChannelClient *rcc, uint16_t msg_type);
 
 uint64_t red_channel_client_get_message_serial(RedChannelClient *channel);
 void red_channel_client_set_message_serial(RedChannelClient *channel, uint64_t);
diff --git a/server/smartcard-channel-client.c b/server/smartcard-channel-client.c
index aece01b..bcdc914 100644
--- a/server/smartcard-channel-client.c
+++ b/server/smartcard-channel-client.c
@@ -220,7 +220,7 @@ void smartcard_channel_client_send_data(RedChannelClient *rcc,
     /* NOTE: 'vheader' is assumed to be owned by 'item' so we keep the pipe
      * item valid until the message is actually sent. */
     red_pipe_item_ref(item);
-    red_channel_client_init_send_data(rcc, SPICE_MSG_SMARTCARD_DATA, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_SMARTCARD_DATA);
     spice_marshaller_add_by_ref_full(m, (uint8_t*)vheader, sizeof(VSCMsgHeader) + vheader->length,
                                      marshaller_free_pipe_item, item);
 }
diff --git a/server/smartcard.c b/server/smartcard.c
index 9e0d968..f4bc40d 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -419,7 +419,7 @@ static void smartcard_channel_send_migrate_data(RedChannelClient *rcc,
 
     scc = SMARTCARD_CHANNEL_CLIENT(rcc);
     dev = smartcard_channel_client_get_char_device(scc);
-    red_channel_client_init_send_data(rcc, SPICE_MSG_MIGRATE_DATA, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_MIGRATE_DATA);
     spice_marshaller_add_uint32(m, SPICE_MIGRATE_DATA_SMARTCARD_MAGIC);
     spice_marshaller_add_uint32(m, SPICE_MIGRATE_DATA_SMARTCARD_VERSION);
 
diff --git a/server/spicevmc.c b/server/spicevmc.c
index 4f93ca4..2a36759 100644
--- a/server/spicevmc.c
+++ b/server/spicevmc.c
@@ -641,10 +641,10 @@ static void spicevmc_red_channel_send_data(RedChannelClient *rcc,
 
     /* for compatibility send using not compressed data message */
     if (i->type == SPICE_DATA_COMPRESSION_TYPE_NONE) {
-        red_channel_client_init_send_data(rcc, SPICE_MSG_SPICEVMC_DATA, NULL);
+        red_channel_client_init_send_data(rcc, SPICE_MSG_SPICEVMC_DATA);
     } else {
         /* send as compressed */
-        red_channel_client_init_send_data(rcc, SPICE_MSG_SPICEVMC_COMPRESSED_DATA, NULL);
+        red_channel_client_init_send_data(rcc, SPICE_MSG_SPICEVMC_COMPRESSED_DATA);
         SpiceMsgCompressedData compressed_msg = {
             .type = i->type,
             .uncompressed_size = i->uncompressed_data_size
@@ -663,7 +663,7 @@ static void spicevmc_red_channel_send_migrate_data(RedChannelClient *rcc,
     RedVmcChannel *channel;
 
     channel = RED_VMC_CHANNEL(red_channel_client_get_channel(rcc));
-    red_channel_client_init_send_data(rcc, SPICE_MSG_MIGRATE_DATA, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_MIGRATE_DATA);
     spice_marshaller_add_uint32(m, SPICE_MIGRATE_DATA_SPICEVMC_MAGIC);
     spice_marshaller_add_uint32(m, SPICE_MIGRATE_DATA_SPICEVMC_VERSION);
 
@@ -677,7 +677,7 @@ static void spicevmc_red_channel_send_port_init(RedChannelClient *rcc,
     RedPortInitPipeItem *i = SPICE_UPCAST(RedPortInitPipeItem, item);
     SpiceMsgPortInit init;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_PORT_INIT, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_PORT_INIT);
     init.name = (uint8_t *)i->name;
     init.name_size = strlen(i->name) + 1;
     init.opened = i->opened;
@@ -691,7 +691,7 @@ static void spicevmc_red_channel_send_port_event(RedChannelClient *rcc,
     RedPortEventPipeItem *i = SPICE_UPCAST(RedPortEventPipeItem, item);
     SpiceMsgPortEvent event;
 
-    red_channel_client_init_send_data(rcc, SPICE_MSG_PORT_EVENT, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_PORT_EVENT);
     event.event = i->event;
     spice_marshall_msg_port_event(m, &event);
 }
-- 
2.7.4

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]