[spice PATCH 32/55] red_channel: introduce PIPE_ITEM_TYPE_EMPTY_MSG

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

 



The pipe item is used for sending messages that don't have body.
---
 server/red_channel.c |   39 +++++++++++++++++++++++++++++++++++++++
 server/red_channel.h |    4 ++++
 2 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/server/red_channel.c b/server/red_channel.c
index 65ef2da..16335a3 100644
--- a/server/red_channel.c
+++ b/server/red_channel.c
@@ -38,6 +38,11 @@
 #include "reds.h"
 #include "main_dispatcher.h"
 
+typedef struct EmptyMsgPipeItem {
+    PipeItem base;
+    int msg;
+} EmptyMsgPipeItem;
+
 static void red_channel_client_event(int fd, int event, void *data);
 static void red_client_add_channel(RedClient *client, RedChannelClient *rcc);
 static void red_client_remove_channel(RedChannelClient *rcc);
@@ -467,6 +472,15 @@ static void red_channel_client_send_migrate(RedChannelClient *rcc)
     red_channel_client_begin_send_message(rcc);
 }
 
+
+static void red_channel_client_send_empty_msg(RedChannelClient *rcc, PipeItem *base)
+{
+    EmptyMsgPipeItem *msg_pipe_item = SPICE_CONTAINEROF(base, EmptyMsgPipeItem, base);
+
+    red_channel_client_init_send_data(rcc, msg_pipe_item->msg, NULL);
+    red_channel_client_begin_send_message(rcc);
+}
+
 static void red_channel_client_send_item(RedChannelClient *rcc, PipeItem *item)
 {
     int handled = TRUE;
@@ -482,6 +496,10 @@ static void red_channel_client_send_item(RedChannelClient *rcc, PipeItem *item)
             red_channel_client_send_migrate(rcc);
             free(item);
             break;
+        case PIPE_ITEM_TYPE_EMPTY_MSG:
+            red_channel_client_send_empty_msg(rcc, item);
+            free(item);
+            break;
         default:
             handled = FALSE;
     }
@@ -1329,6 +1347,27 @@ void red_channel_pipes_add_type(RedChannel *channel, int pipe_item_type)
     }
 }
 
+void red_channel_client_pipe_add_empty_msg(RedChannelClient *rcc, int msg_type)
+{
+    EmptyMsgPipeItem *item = spice_new(EmptyMsgPipeItem, 1);
+
+    red_channel_pipe_item_init(rcc->channel, &item->base, PIPE_ITEM_TYPE_EMPTY_MSG);
+    item->msg = msg_type;
+    red_channel_client_pipe_add(rcc, &item->base);
+    red_channel_client_push(rcc);
+}
+
+void red_channel_pipes_add_empty_msg(RedChannel *channel, int msg_type)
+{
+    RingItem *link;
+
+    RING_FOREACH(link, &channel->clients) {
+        red_channel_client_pipe_add_empty_msg(
+            SPICE_CONTAINEROF(link, RedChannelClient, channel_link),
+            msg_type);
+    }
+}
+
 int red_channel_client_is_connected(RedChannelClient *rcc)
 {
     return rcc->stream != NULL;
diff --git a/server/red_channel.h b/server/red_channel.h
index 8c8e1c8..de72fff 100644
--- a/server/red_channel.h
+++ b/server/red_channel.h
@@ -143,6 +143,7 @@ typedef struct MainChannelClient MainChannelClient;
 enum {
     PIPE_ITEM_TYPE_SET_ACK=1,
     PIPE_ITEM_TYPE_MIGRATE,
+    PIPE_ITEM_TYPE_EMPTY_MSG,
 
     PIPE_ITEM_TYPE_CHANNEL_BASE=101,
 };
@@ -438,6 +439,9 @@ void red_channel_client_pipe_add_tail(RedChannelClient *rcc, PipeItem *item);
 void red_channel_client_pipe_add_type(RedChannelClient *rcc, int pipe_item_type);
 void red_channel_pipes_add_type(RedChannel *channel, int pipe_item_type);
 
+void red_channel_client_pipe_add_empty_msg(RedChannelClient *rcc, int msg_type);
+void red_channel_pipes_add_empty_msg(RedChannel *channel, int msg_type);
+
 void red_channel_client_ack_zero_messages_window(RedChannelClient *rcc);
 void red_channel_client_ack_set_client_window(RedChannelClient *rcc, int client_window);
 void red_channel_client_push_set_ack(RedChannelClient *rcc);
-- 
1.7.7.6

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://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]