diff options
author | Alon Levy <alevy@redhat.com> | 2011-04-11 20:58:01 +0300 |
---|---|---|
committer | Alon Levy <alevy@redhat.com> | 2011-08-23 17:58:01 +0300 |
commit | 4e304ff40f89c8619d462b584ee6ad7d6e10ce93 (patch) | |
tree | 8f8aefb97f4ef416219c2e4e5c668b9993736fde /server/main_channel.c | |
parent | d65b08e12d337379e9c62112565ced8d1839c10a (diff) | |
download | spice-4e304ff40f89c8619d462b584ee6ad7d6e10ce93.tar.gz spice-4e304ff40f89c8619d462b584ee6ad7d6e10ce93.tar.xz spice-4e304ff40f89c8619d462b584ee6ad7d6e10ce93.zip |
server/main_channel: move connection_id from reds
Expose additional api to find a client given a connection_id. The connection_id
is first set when the first channel connects, which is the main channel.
It could also be kept in the RedClient instead, not sure.
TODO:
multiple todo's added for multiclient handling. I don't remember why
I wrote them exactly, and besides if I did any migration tests. So: TODO.
Diffstat (limited to 'server/main_channel.c')
-rw-r--r-- | server/main_channel.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/server/main_channel.c b/server/main_channel.c index d9f69434..b2f12cd3 100644 --- a/server/main_channel.c +++ b/server/main_channel.c @@ -121,6 +121,7 @@ typedef struct MultiMediaTimePipeItem { struct MainChannelClient { RedChannelClient base; + uint32_t connection_id; uint32_t ping_id; uint32_t net_test_id; int net_test_stage; @@ -154,6 +155,20 @@ static void main_disconnect(MainChannel *main_chan) red_channel_destroy(&main_chan->base); } +RedClient *main_channel_get_client_by_link_id(MainChannel *main_chan, uint32_t connection_id) +{ + MainChannelClient *mcc; + + if (!main_chan || !main_chan->base.rcc) { + return NULL; + } + mcc = SPICE_CONTAINEROF(main_chan->base.rcc, MainChannelClient, base); + if (mcc->connection_id == connection_id) { + return mcc->base.client; + } + return NULL; +} + static int main_channel_client_push_ping(MainChannelClient *rcc, int size); void main_channel_start_net_test(MainChannelClient *mcc) @@ -861,11 +876,12 @@ static void ping_timer_cb(void *opaque) #endif /* RED_STATISTICS */ MainChannelClient *main_channel_client_create(MainChannel *main_chan, - RedClient *client, RedsStream *stream) + RedClient *client, RedsStream *stream, uint32_t connection_id) { MainChannelClient *mcc = (MainChannelClient*)red_channel_client_create( sizeof(MainChannelClient), &main_chan->base, client, stream); + mcc->connection_id = connection_id; mcc->bitrate_per_sec = ~0; #ifdef RED_STATISTICS if (!(mcc->ping_timer = core->timer_add(ping_timer_cb, NULL))) { @@ -877,7 +893,7 @@ MainChannelClient *main_channel_client_create(MainChannel *main_chan, } MainChannelClient *main_channel_link(Channel *channel, RedClient *client, - RedsStream *stream, int migration, + RedsStream *stream, uint32_t connection_id, int migration, int num_common_caps, uint32_t *common_caps, int num_caps, uint32_t *caps) { @@ -904,7 +920,7 @@ MainChannelClient *main_channel_link(Channel *channel, RedClient *client, ASSERT(channel->data); } red_printf("add main channel client"); - mcc = main_channel_client_create(channel->data, client, stream); + mcc = main_channel_client_create(channel->data, client, stream, connection_id); return mcc; } |