diff options
author | Alon Levy <alevy@redhat.com> | 2011-04-24 10:32:10 +0300 |
---|---|---|
committer | Alon Levy <alevy@redhat.com> | 2011-08-23 17:56:46 +0300 |
commit | 614df171931ebc746652537215a5ce83bdf8a458 (patch) | |
tree | d477f0a5e97f3c0ea9fb1744aa74648f55f4dd2a | |
parent | 448ed75bd6c8db7ca48cab8aa1256a262e87fcc0 (diff) | |
download | spice-614df171931ebc746652537215a5ce83bdf8a458.tar.gz spice-614df171931ebc746652537215a5ce83bdf8a458.tar.xz spice-614df171931ebc746652537215a5ce83bdf8a458.zip |
server/reds: add concept of secondary channels
Secondary channels are those that don't support multiple clients. The
support added in this patch just doesn't let the second or more connected
client receive the unsupported channels in the channels list sent by the
server to the client. This doesn't handle the situation where:
client A connects (gets all channels)
client B connects (gets supported multiple client channels)
client A disconnects (Suboptimal 1: B doesn't get new channels at this point)
client C connects (Suboptimal 2: C doesn't get the full list of channels, but
the partial one)
Specifically the channels that only support a single client are:
sound (both playback and record channels)
smartcard
tunnel
-rw-r--r-- | server/reds.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/server/reds.c b/server/reds.c index c4a05d53..a10dd3ec 100644 --- a/server/reds.c +++ b/server/reds.c @@ -982,18 +982,40 @@ int reds_num_of_channels() return reds ? reds->num_of_channels : 0; } +static int secondary_channels[] = { + SPICE_CHANNEL_MAIN, SPICE_CHANNEL_DISPLAY, SPICE_CHANNEL_CURSOR, SPICE_CHANNEL_INPUTS}; + +static int channel_is_secondary(Channel *channel) +{ + int i; + for (i = 0 ; i < sizeof(secondary_channels)/sizeof(secondary_channels[0]); ++i) { + if (channel->type == secondary_channels[i]) { + return TRUE; + } + } + return FALSE; +} + void reds_fill_channels(SpiceMsgChannels *channels_info) { Channel *channel; int i; + int used_channels = 0; channels_info->num_of_channels = reds->num_of_channels; channel = reds->channels; - for (i = 0; i < reds->num_of_channels; i++) { + for (i = 0; i < reds->num_of_channels; i++, channel = channel->next) { ASSERT(channel); - channels_info->channels[i].type = channel->type; - channels_info->channels[i].id = channel->id; - channel = channel->next; + if (reds->num_clients > 1 && !channel_is_secondary(channel)) { + continue; + } + channels_info->channels[used_channels].type = channel->type; + channels_info->channels[used_channels].id = channel->id; + used_channels++; + } + channels_info->num_of_channels = used_channels; + if (used_channels != reds->num_of_channels) { + red_printf("sent %d out of %d", used_channels, reds->num_of_channels); } } |