[PATCH 16/23] use a default release_item implementation in RedChannel

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

 



Avoid having to provide a lot of empty implementations

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 server/cursor-channel.c  |  6 ------
 server/display-channel.c |  6 ------
 server/inputs-channel.c  |  7 -------
 server/red-channel.c     | 10 +++++++++-
 server/smartcard.c       |  7 -------
 server/spicevmc.c        |  8 --------
 6 files changed, 9 insertions(+), 35 deletions(-)

diff --git a/server/cursor-channel.c b/server/cursor-channel.c
index b0fd95f..c0b2fda 100644
--- a/server/cursor-channel.c
+++ b/server/cursor-channel.c
@@ -359,11 +359,6 @@ static void cursor_channel_hold_pipe_item(RedChannelClient *rcc, RedPipeItem *it
     cursor_pipe_item_ref(cursor_pipe_item);
 }
 
-static void cursor_channel_release_item(RedChannelClient *rcc, RedPipeItem *item, int item_pushed)
-{
-    red_pipe_item_unref(item);
-}
-
 CursorChannel* cursor_channel_new(RedWorker *worker)
 {
     CursorChannel *cursor_channel;
@@ -372,7 +367,6 @@ CursorChannel* cursor_channel_new(RedWorker *worker)
         .on_disconnect =  cursor_channel_client_on_disconnect,
         .send_item = cursor_channel_send_item,
         .hold_item = cursor_channel_hold_pipe_item,
-        .release_item = cursor_channel_release_item
     };
 
     spice_info("create cursor channel");
diff --git a/server/display-channel.c b/server/display-channel.c
index b559a4e..5ef7920 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -1979,11 +1979,6 @@ static void hold_item(RedChannelClient *rcc, RedPipeItem *item)
     }
 }
 
-static void release_item(RedChannelClient *rcc, RedPipeItem *item, int item_pushed)
-{
-    red_pipe_item_unref(item);
-}
-
 static int handle_migrate_flush_mark(RedChannelClient *rcc)
 {
     DisplayChannel *display_channel = SPICE_CONTAINEROF(rcc->channel, DisplayChannel, common.base);
@@ -2025,7 +2020,6 @@ DisplayChannel* display_channel_new(SpiceServer *reds, RedWorker *worker,
         .on_disconnect = on_disconnect,
         .send_item = send_item,
         .hold_item = hold_item,
-        .release_item = release_item,
         .handle_migrate_flush_mark = handle_migrate_flush_mark,
         .handle_migrate_data = handle_migrate_data,
         .handle_migrate_data_get_serial = handle_migrate_data_get_serial
diff --git a/server/inputs-channel.c b/server/inputs-channel.c
index 0ce12de..a3c9fb2 100644
--- a/server/inputs-channel.c
+++ b/server/inputs-channel.c
@@ -254,12 +254,6 @@ static void inputs_channel_send_migrate_data(RedChannelClient *rcc,
     spice_marshaller_add_uint16(m, icc->motion_count);
 }
 
-static void inputs_channel_release_pipe_item(RedChannelClient *rcc,
-    RedPipeItem *base, int item_pushed)
-{
-    free(base);
-}
-
 static void inputs_channel_send_item(RedChannelClient *rcc, RedPipeItem *base)
 {
     SpiceMarshaller *m = red_channel_client_get_marshaller(rcc);
@@ -627,7 +621,6 @@ InputsChannel* inputs_channel_new(RedsState *reds)
     channel_cbs.on_disconnect = inputs_channel_on_disconnect;
     channel_cbs.send_item = inputs_channel_send_item;
     channel_cbs.hold_item = inputs_channel_hold_pipe_item;
-    channel_cbs.release_item = inputs_channel_release_pipe_item;
     channel_cbs.alloc_recv_buf = inputs_channel_alloc_msg_rcv_buf;
     channel_cbs.release_recv_buf = inputs_channel_release_msg_rcv_buf;
     channel_cbs.handle_migrate_data = inputs_channel_handle_migrate_data;
diff --git a/server/red-channel.c b/server/red-channel.c
index a99c6c6..0d35fc0 100644
--- a/server/red-channel.c
+++ b/server/red-channel.c
@@ -1016,6 +1016,11 @@ void red_channel_client_default_migrate(RedChannelClient *rcc)
     red_channel_client_pipe_add_type(rcc, RED_PIPE_ITEM_TYPE_MIGRATE);
 }
 
+static void red_channel_release_item(RedChannelClient *rcc, RedPipeItem *item, int item_pushed)
+{
+    red_pipe_item_unref(item);
+}
+
 RedChannel *red_channel_create(int size,
                                RedsState *reds,
                                const SpiceCoreInterfaceInternal *core,
@@ -1030,7 +1035,7 @@ RedChannel *red_channel_create(int size,
 
     spice_assert(size >= sizeof(*channel));
     spice_assert(channel_cbs->config_socket && channel_cbs->on_disconnect && handle_message &&
-           channel_cbs->alloc_recv_buf && channel_cbs->release_item);
+           channel_cbs->alloc_recv_buf);
     spice_assert(channel_cbs->handle_migrate_data ||
                  !(migration_flags & SPICE_MIGRATE_NEED_DATA_TRANSFER));
     channel = spice_malloc0(size);
@@ -1040,6 +1045,9 @@ RedChannel *red_channel_create(int size,
     channel->handle_acks = handle_acks;
     channel->migration_flags = migration_flags;
     memcpy(&channel->channel_cbs, channel_cbs, sizeof(ChannelCbs));
+    if (!channel->channel_cbs.release_item) {
+        channel->channel_cbs.release_item = red_channel_release_item;
+    }
 
     channel->reds = reds;
     channel->core = core;
diff --git a/server/smartcard.c b/server/smartcard.c
index c8e9eb0..a75f01c 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -504,12 +504,6 @@ static void smartcard_channel_send_item(RedChannelClient *rcc, RedPipeItem *item
     red_channel_client_begin_send_message(rcc);
 }
 
-static void smartcard_channel_release_pipe_item(RedChannelClient *rcc,
-                                      RedPipeItem *item, int item_pushed)
-{
-    red_pipe_item_unref(item);
-}
-
 static void smartcard_channel_on_disconnect(RedChannelClient *rcc)
 {
     SmartCardChannelClient *scc = SPICE_CONTAINEROF(rcc, SmartCardChannelClient, base);
@@ -792,7 +786,6 @@ static void smartcard_init(RedsState *reds)
     channel_cbs.on_disconnect = smartcard_channel_on_disconnect;
     channel_cbs.send_item = smartcard_channel_send_item;
     channel_cbs.hold_item = smartcard_channel_hold_pipe_item;
-    channel_cbs.release_item = smartcard_channel_release_pipe_item;
     channel_cbs.alloc_recv_buf = smartcard_channel_alloc_msg_rcv_buf;
     channel_cbs.release_recv_buf = smartcard_channel_release_msg_rcv_buf;
     channel_cbs.handle_migrate_flush_mark = smartcard_channel_client_handle_migrate_flush_mark;
diff --git a/server/spicevmc.c b/server/spicevmc.c
index 5724023..1e9406e 100644
--- a/server/spicevmc.c
+++ b/server/spicevmc.c
@@ -437,13 +437,6 @@ static void spicevmc_red_channel_send_item(RedChannelClient *rcc,
     red_channel_client_begin_send_message(rcc);
 }
 
-static void spicevmc_red_channel_release_pipe_item(RedChannelClient *rcc,
-                                                   RedPipeItem *item,
-                                                   int item_pushed)
-{
-    red_pipe_item_unref(item);
-}
-
 static void spicevmc_connect(RedChannel *channel, RedClient *client,
     RedsStream *stream, int migration, int num_common_caps,
     uint32_t *common_caps, int num_caps, uint32_t *caps)
@@ -505,7 +498,6 @@ RedCharDevice *spicevmc_device_connect(RedsState *reds,
     channel_cbs.on_disconnect = spicevmc_red_channel_client_on_disconnect;
     channel_cbs.send_item = spicevmc_red_channel_send_item;
     channel_cbs.hold_item = spicevmc_red_channel_hold_pipe_item;
-    channel_cbs.release_item = spicevmc_red_channel_release_pipe_item;
     channel_cbs.alloc_recv_buf = spicevmc_red_channel_alloc_msg_rcv_buf;
     channel_cbs.release_recv_buf = spicevmc_red_channel_release_msg_rcv_buf;
     channel_cbs.handle_migrate_flush_mark = spicevmc_channel_client_handle_migrate_flush_mark;
-- 
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]