diff options
author | Alon Levy <alevy@redhat.com> | 2011-07-03 18:56:33 +0200 |
---|---|---|
committer | Alon Levy <alevy@redhat.com> | 2011-08-23 18:01:04 +0300 |
commit | a32e90257e834e340075e633132b52c612be4578 (patch) | |
tree | 36580206b7810f82878958e1c6f16fbcab122e9a /server/red_client_cache.h | |
parent | 406751888ecade931eab99dd4c4e3a76de7252c8 (diff) | |
download | spice-a32e90257e834e340075e633132b52c612be4578.tar.gz spice-a32e90257e834e340075e633132b52c612be4578.tar.xz spice-a32e90257e834e340075e633132b52c612be4578.zip |
server/red_worker: multiple client support - base split
This patch compiles but breaks spice.
Split both display and cursor channels to a client part and channel part.
Introduce DisplayChannelClient, CursorChannelClient, CommonChannelClient.
don't disconnect channel on client disconnect.
Move all caches to the ChannelClient's.
Remove reference counting of the channel.
No new functionality introduced.
NOTE: Introduces a crash in disconnections, a regression, resulting from
incorrect thread access, that is fixed in the patch titled:
"server: registering RedChannel in reds, instead of Channel"
Diffstat (limited to 'server/red_client_cache.h')
-rw-r--r-- | server/red_client_cache.h | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/server/red_client_cache.h b/server/red_client_cache.h index 6c17ba61..0da11a65 100644 --- a/server/red_client_cache.h +++ b/server/red_client_cache.h @@ -24,7 +24,7 @@ #define FUNC_NAME(name) red_cursor_cache_##name #define VAR_NAME(name) cursor_cache_##name #define CHANNEL CursorChannel -#define CHANNELCLIENT RedChannelClient +#define CHANNELCLIENT CursorChannelClient #elif defined(CLIENT_PALETTE_CACHE) @@ -35,7 +35,7 @@ #define FUNC_NAME(name) red_palette_cache_##name #define VAR_NAME(name) palette_cache_##name #define CHANNEL DisplayChannel -#define CHANNELCLIENT RedChannelClient +#define CHANNELCLIENT DisplayChannelClient #else #error "no cache type." @@ -44,14 +44,14 @@ #define CHANNEL_FROM_RCC(rcc) SPICE_CONTAINEROF((rcc)->channel, CHANNEL, common.base); -static CacheItem *FUNC_NAME(find)(CHANNEL *channel, uint64_t id) +static CacheItem *FUNC_NAME(find)(CHANNELCLIENT *channel_client, uint64_t id) { - CacheItem *item = channel->CACHE_NAME[CACHE_HASH_KEY(id)]; + CacheItem *item = channel_client->CACHE_NAME[CACHE_HASH_KEY(id)]; while (item) { if (item->id == id) { ring_remove(&item->u.cache_data.lru_link); - ring_add(&channel->VAR_NAME(lru), &item->u.cache_data.lru_link); + ring_add(&channel_client->VAR_NAME(lru), &item->u.cache_data.lru_link); break; } item = item->u.cache_data.next; @@ -62,10 +62,10 @@ static CacheItem *FUNC_NAME(find)(CHANNEL *channel, uint64_t id) static void FUNC_NAME(remove)(CHANNELCLIENT *channel_client, CacheItem *item) { CacheItem **now; - CHANNEL *channel = CHANNEL_FROM_RCC(channel_client); + CHANNEL *channel = CHANNEL_FROM_RCC(&channel_client->common.base); ASSERT(item); - now = &channel->CACHE_NAME[CACHE_HASH_KEY(item->id)]; + now = &channel_client->CACHE_NAME[CACHE_HASH_KEY(item->id)]; for (;;) { ASSERT(*now); if (*now == item) { @@ -75,56 +75,55 @@ static void FUNC_NAME(remove)(CHANNELCLIENT *channel_client, CacheItem *item) now = &(*now)->u.cache_data.next; } ring_remove(&item->u.cache_data.lru_link); - channel->VAR_NAME(items)--; - channel->VAR_NAME(available) += item->size; + channel_client->VAR_NAME(items)--; + channel_client->VAR_NAME(available) += item->size; red_channel_pipe_item_init(&channel->common.base, &item->u.pipe_data, PIPE_ITEM_TYPE_INVAL_ONE); - red_channel_client_pipe_add_tail(channel_client, &item->u.pipe_data); // for now + red_channel_client_pipe_add_tail(&channel_client->common.base, &item->u.pipe_data); // for now } static int FUNC_NAME(add)(CHANNELCLIENT *channel_client, uint64_t id, size_t size) { - CHANNEL *channel = CHANNEL_FROM_RCC(channel_client); CacheItem *item; int key; item = spice_new(CacheItem, 1); - channel->VAR_NAME(available) -= size; - while (channel->VAR_NAME(available) < 0) { - CacheItem *tail = (CacheItem *)ring_get_tail(&channel->VAR_NAME(lru)); + channel_client->VAR_NAME(available) -= size; + while (channel_client->VAR_NAME(available) < 0) { + CacheItem *tail = (CacheItem *)ring_get_tail(&channel_client->VAR_NAME(lru)); if (!tail) { - channel->VAR_NAME(available) += size; + channel_client->VAR_NAME(available) += size; free(item); return FALSE; } FUNC_NAME(remove)(channel_client, tail); } - ++channel->VAR_NAME(items); - item->u.cache_data.next = channel->CACHE_NAME[(key = CACHE_HASH_KEY(id))]; - channel->CACHE_NAME[key] = item; + ++channel_client->VAR_NAME(items); + item->u.cache_data.next = channel_client->CACHE_NAME[(key = CACHE_HASH_KEY(id))]; + channel_client->CACHE_NAME[key] = item; ring_item_init(&item->u.cache_data.lru_link); - ring_add(&channel->VAR_NAME(lru), &item->u.cache_data.lru_link); + ring_add(&channel_client->VAR_NAME(lru), &item->u.cache_data.lru_link); item->id = id; item->size = size; item->inval_type = CACHE_INVAL_TYPE; return TRUE; } -static void FUNC_NAME(reset)(CHANNEL *channel, long size) +static void FUNC_NAME(reset)(CHANNELCLIENT *channel_client, long size) { int i; for (i = 0; i < CACHE_HASH_SIZE; i++) { - while (channel->CACHE_NAME[i]) { - CacheItem *item = channel->CACHE_NAME[i]; - channel->CACHE_NAME[i] = item->u.cache_data.next; + while (channel_client->CACHE_NAME[i]) { + CacheItem *item = channel_client->CACHE_NAME[i]; + channel_client->CACHE_NAME[i] = item->u.cache_data.next; free(item); } } - ring_init(&channel->VAR_NAME(lru)); - channel->VAR_NAME(available) = size; - channel->VAR_NAME(items) = 0; + ring_init(&channel_client->VAR_NAME(lru)); + channel_client->VAR_NAME(available) = size; + channel_client->VAR_NAME(items) = 0; } @@ -136,4 +135,5 @@ static void FUNC_NAME(reset)(CHANNEL *channel, long size) #undef FUNC_NAME #undef VAR_NAME #undef CHANNEL +#undef CHANNELCLIENT #undef CHANNEL_FROM_RCC |