[PATCH spice-server v2 4/6] red-channel: Reuse red_channel_pipes_add

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

 



Implements red_channel_pipes_add_type and
red_channel_pipes_add_empty_msg using red_channel_pipes_add.
This avoid duplicating items for each client.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
Acked-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
---
 server/red-channel-client.c |  9 +++++++--
 server/red-channel-client.h |  1 +
 server/red-channel.c        | 20 +++++---------------
 3 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index c45988b9..69bd09de 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -1593,13 +1593,18 @@ void red_channel_client_pipe_add_type(RedChannelClient *rcc, int pipe_item_type)
     red_channel_client_pipe_add(rcc, item);
 }
 
-void red_channel_client_pipe_add_empty_msg(RedChannelClient *rcc, int msg_type)
+RedPipeItem *red_channel_client_new_empty_msg(int msg_type)
 {
     RedEmptyMsgPipeItem *item = spice_new(RedEmptyMsgPipeItem, 1);
 
     red_pipe_item_init(&item->base, RED_PIPE_ITEM_TYPE_EMPTY_MSG);
     item->msg = msg_type;
-    red_channel_client_pipe_add(rcc, &item->base);
+    return &item->base;
+}
+
+void red_channel_client_pipe_add_empty_msg(RedChannelClient *rcc, int msg_type)
+{
+    red_channel_client_pipe_add(rcc, red_channel_client_new_empty_msg(msg_type));
 }
 
 gboolean red_channel_client_pipe_is_empty(RedChannelClient *rcc)
diff --git a/server/red-channel-client.h b/server/red-channel-client.h
index 3665dacc..f5e04df7 100644
--- a/server/red-channel-client.h
+++ b/server/red-channel-client.h
@@ -99,6 +99,7 @@ void red_channel_client_pipe_add_tail(RedChannelClient *rcc, RedPipeItem *item);
 void red_channel_client_pipe_add_tail_and_push(RedChannelClient *rcc, RedPipeItem *item);
 /* for types that use this routine -> the pipe item should be freed */
 void red_channel_client_pipe_add_type(RedChannelClient *rcc, int pipe_item_type);
+RedPipeItem *red_channel_client_new_empty_msg(int msg_type);
 void red_channel_client_pipe_add_empty_msg(RedChannelClient *rcc, int msg_type);
 gboolean red_channel_client_pipe_is_empty(RedChannelClient *rcc);
 uint32_t red_channel_client_get_pipe_size(RedChannelClient *rcc);
diff --git a/server/red-channel.c b/server/red-channel.c
index 4229794d..a2c068e5 100644
--- a/server/red-channel.c
+++ b/server/red-channel.c
@@ -441,28 +441,18 @@ void red_channel_pipes_add(RedChannel *channel, RedPipeItem *item)
     red_pipe_item_unref(item);
 }
 
-static void red_channel_client_pipe_add_type_proxy(gpointer data, gpointer user_data)
-{
-    int type = GPOINTER_TO_INT(user_data);
-    red_channel_client_pipe_add_type(data, type);
-}
-
 void red_channel_pipes_add_type(RedChannel *channel, int pipe_item_type)
 {
-    g_list_foreach(channel->priv->clients, red_channel_client_pipe_add_type_proxy,
-                   GINT_TO_POINTER(pipe_item_type));
-}
+    RedPipeItem *item = spice_new(RedPipeItem, 1);
 
-static void red_channel_client_pipe_add_empty_msg_proxy(gpointer data, gpointer user_data)
-{
-    int type = GPOINTER_TO_INT(user_data);
-    red_channel_client_pipe_add_empty_msg(data, type);
+    red_pipe_item_init(item, pipe_item_type);
+
+    red_channel_pipes_add(channel, item);
 }
 
 void red_channel_pipes_add_empty_msg(RedChannel *channel, int msg_type)
 {
-    g_list_foreach(channel->priv->clients, red_channel_client_pipe_add_empty_msg_proxy,
-                   GINT_TO_POINTER(msg_type));
+    red_channel_pipes_add(channel, red_channel_client_new_empty_msg(msg_type));
 }
 
 int red_channel_is_connected(RedChannel *channel)
-- 
2.13.5

_______________________________________________
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]