summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYonit Halperin <yhalperi@redhat.com>2012-08-05 14:16:05 +0300
committerYonit Halperin <yhalperi@redhat.com>2012-08-27 09:13:06 +0300
commit157d459d4265e2141095fedc58469545bb0fc2f0 (patch)
treedd0f2ecc1298467e638340f41a93bbb124141177
parentfdab42cc41e1fcee34de564e80e16890c5d86882 (diff)
downloadspice-157d459d4265e2141095fedc58469545bb0fc2f0.tar.gz
spice-157d459d4265e2141095fedc58469545bb0fc2f0.tar.xz
spice-157d459d4265e2141095fedc58469545bb0fc2f0.zip
red_channel: introduce PIPE_ITEM_TYPE_EMPTY_MSG
The pipe item is used for sending messages that don't have body.
-rw-r--r--server/red_channel.c39
-rw-r--r--server/red_channel.h4
2 files changed, 43 insertions, 0 deletions
diff --git a/server/red_channel.c b/server/red_channel.c
index 65ef2da5..16335a32 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 8c8e1c8b..de72fffb 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);