summaryrefslogtreecommitdiffstats
path: root/server/main_channel.c
diff options
context:
space:
mode:
authorYonit Halperin <yhalperi@redhat.com>2012-06-24 12:07:09 +0300
committerYonit Halperin <yhalperi@redhat.com>2012-07-03 14:13:41 +0300
commitfffa38672ce53c07a3341798e2bd66d806e8cf0d (patch)
tree2df692ee1395602daf0cc76a4cfb9991370e5d4c /server/main_channel.c
parent50e3af6a995eb8aeee8bd8fb82a5cf6aa93f21cf (diff)
downloadspice-fffa38672ce53c07a3341798e2bd66d806e8cf0d.tar.gz
spice-fffa38672ce53c07a3341798e2bd66d806e8cf0d.tar.xz
spice-fffa38672ce53c07a3341798e2bd66d806e8cf0d.zip
agent: Fix tokens handling in main_channel
- Allow sending tokens to a specific client. - Do not ignore tokens that are sent from the client to the server. The tokens support for multiple clients and for server side tokens is still broken in reds. It will be fixed in following patches, when the server-side agent code will use the SpiceCharDeviceState api. Notice that ignoring the server-side tokens didn't introduce a problem since both the client and the server set it to ~0.
Diffstat (limited to 'server/main_channel.c')
-rw-r--r--server/main_channel.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/server/main_channel.c b/server/main_channel.c
index ace24ff6..ce467f83 100644
--- a/server/main_channel.c
+++ b/server/main_channel.c
@@ -222,18 +222,13 @@ static PipeItem *main_ping_item_new(MainChannelClient *mcc, int size)
return &item->base;
}
-typedef struct MainTokensItemInfo {
- uint32_t num_tokens;
-} MainTokensItemInfo;
-
-static PipeItem *main_tokens_item_new(RedChannelClient *rcc, void *data, int num)
+static PipeItem *main_agent_tokens_item_new(RedChannelClient *rcc, uint32_t num_tokens)
{
TokensPipeItem *item = spice_malloc(sizeof(TokensPipeItem));
- MainTokensItemInfo *init = data;
red_channel_pipe_item_init(rcc->channel, &item->base,
SPICE_MSG_MAIN_AGENT_TOKEN);
- item->tokens = init->num_tokens;
+ item->tokens = num_tokens;
return &item->base;
}
@@ -422,13 +417,11 @@ static void main_channel_marshall_agent_disconnected(SpiceMarshaller *m)
spice_marshall_msg_main_agent_disconnected(m, &disconnect);
}
-// TODO: make this targeted (requires change to agent token accounting)
-void main_channel_push_tokens(MainChannel *main_chan, uint32_t num_tokens)
+void main_channel_client_push_agent_tokens(MainChannelClient *mcc, uint32_t num_tokens)
{
- MainTokensItemInfo init = {.num_tokens = num_tokens};
+ PipeItem *item = main_agent_tokens_item_new(&mcc->base, num_tokens);
- red_channel_pipes_new_add_push(&main_chan->base,
- main_tokens_item_new, &init);
+ red_channel_client_pipe_add_push(&mcc->base, item);
}
static void main_channel_marshall_tokens(SpiceMarshaller *m, uint32_t num_tokens)
@@ -828,19 +821,28 @@ static int main_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, uint
MainChannelClient *mcc = SPICE_CONTAINEROF(rcc, MainChannelClient, base);
switch (type) {
- case SPICE_MSGC_MAIN_AGENT_START:
+ case SPICE_MSGC_MAIN_AGENT_START: {
+ SpiceMsgcMainAgentStart *tokens;
+
spice_printerr("agent start");
if (!main_chan) {
return FALSE;
}
- reds_on_main_agent_start();
+ tokens = (SpiceMsgcMainAgentStart *)message;
+ reds_on_main_agent_start(mcc, tokens->num_tokens);
break;
+ }
case SPICE_MSGC_MAIN_AGENT_DATA: {
reds_on_main_agent_data(mcc, message, size);
break;
}
- case SPICE_MSGC_MAIN_AGENT_TOKEN:
+ case SPICE_MSGC_MAIN_AGENT_TOKEN: {
+ SpiceMsgcMainAgentTokens *tokens;
+
+ tokens = (SpiceMsgcMainAgentTokens *)message;
+ reds_on_main_agent_tokens(mcc, tokens->num_tokens);
break;
+ }
case SPICE_MSGC_MAIN_ATTACH_CHANNELS:
main_channel_push_channels(mcc);
break;