summaryrefslogtreecommitdiffstats
path: root/server/red_client_shared_cache.h
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2011-07-03 18:56:33 +0200
committerAlon Levy <alevy@redhat.com>2011-08-23 18:01:04 +0300
commita32e90257e834e340075e633132b52c612be4578 (patch)
tree36580206b7810f82878958e1c6f16fbcab122e9a /server/red_client_shared_cache.h
parent406751888ecade931eab99dd4c4e3a76de7252c8 (diff)
downloadspice-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_shared_cache.h')
-rw-r--r--server/red_client_shared_cache.h50
1 files changed, 24 insertions, 26 deletions
diff --git a/server/red_client_shared_cache.h b/server/red_client_shared_cache.h
index 6b1f975a..ed3f1dab 100644
--- a/server/red_client_shared_cache.h
+++ b/server/red_client_shared_cache.h
@@ -26,7 +26,6 @@
#define FUNC_NAME(name) pixmap_cache_##name
#define PRIVATE_FUNC_NAME(name) __pixmap_cache_##name
#define CHANNEL DisplayChannel
-#define CHANNEL_FROM_RCC(rcc) SPICE_CONTAINEROF(rcc->channel, CHANNEL, common.base);
#define CACH_GENERATION pixmap_cache_generation
#define INVAL_ALL_VERB SPICE_MSG_DISPLAY_INVAL_ALL_PIXMAPS
#else
@@ -35,14 +34,14 @@
#endif
+#define CHANNEL_FROM_RCC(rcc) SPICE_CONTAINEROF((rcc)->channel, CHANNEL, common.base);
-static int FUNC_NAME(hit)(CACHE *cache, uint64_t id, int *lossy, RedChannelClient *rcc)
+static int FUNC_NAME(hit)(CACHE *cache, uint64_t id, int *lossy, DisplayChannelClient *dcc)
{
- CHANNEL *channel = CHANNEL_FROM_RCC(rcc);
NewCacheItem *item;
uint64_t serial;
- serial = red_channel_client_get_message_serial(rcc);
+ serial = red_channel_client_get_message_serial(&dcc->common.base);
pthread_mutex_lock(&cache->lock);
item = cache->hash_table[CACHE_HASH_KEY(id)];
@@ -50,9 +49,9 @@ static int FUNC_NAME(hit)(CACHE *cache, uint64_t id, int *lossy, RedChannelClien
if (item->id == id) {
ring_remove(&item->lru_link);
ring_add(&cache->lru, &item->lru_link);
- ASSERT(channel->common.id < MAX_CACHE_CLIENTS)
- item->sync[channel->common.id] = serial;
- cache->sync[channel->common.id] = serial;
+ ASSERT(dcc->common.id < MAX_CACHE_CLIENTS)
+ item->sync[dcc->common.id] = serial;
+ cache->sync[dcc->common.id] = serial;
*lossy = item->lossy;
break;
}
@@ -81,9 +80,8 @@ static int FUNC_NAME(set_lossy)(CACHE *cache, uint64_t id, int lossy)
return !!item;
}
-static int FUNC_NAME(add)(CACHE *cache, uint64_t id, uint32_t size, int lossy, RedChannelClient *rcc)
+static int FUNC_NAME(add)(CACHE *cache, uint64_t id, uint32_t size, int lossy, DisplayChannelClient *dcc)
{
- CHANNEL *channel = CHANNEL_FROM_RCC(rcc);
NewCacheItem *item;
uint64_t serial;
int key;
@@ -91,14 +89,15 @@ static int FUNC_NAME(add)(CACHE *cache, uint64_t id, uint32_t size, int lossy, R
ASSERT(size > 0);
item = spice_new(NewCacheItem, 1);
- serial = red_channel_client_get_message_serial(rcc);
+ serial = red_channel_client_get_message_serial(&dcc->common.base);
pthread_mutex_lock(&cache->lock);
- if (cache->generation != channel->CACH_GENERATION) {
- if (!channel->pending_pixmaps_sync) {
- red_channel_client_pipe_add_type(rcc, PIPE_ITEM_TYPE_PIXMAP_SYNC);
- channel->pending_pixmaps_sync = TRUE;
+ if (cache->generation != dcc->CACH_GENERATION) {
+ if (!dcc->pending_pixmaps_sync) {
+ red_channel_client_pipe_add_type(
+ &dcc->common.base, PIPE_ITEM_TYPE_PIXMAP_SYNC);
+ dcc->pending_pixmaps_sync = TRUE;
}
pthread_mutex_unlock(&cache->lock);
free(item);
@@ -111,7 +110,7 @@ static int FUNC_NAME(add)(CACHE *cache, uint64_t id, uint32_t size, int lossy, R
NewCacheItem **now;
if (!(tail = (NewCacheItem *)ring_get_tail(&cache->lru)) ||
- tail->sync[channel->common.id] == serial) {
+ tail->sync[dcc->common.id] == serial) {
cache->available += size;
pthread_mutex_unlock(&cache->lock);
free(item);
@@ -130,8 +129,8 @@ static int FUNC_NAME(add)(CACHE *cache, uint64_t id, uint32_t size, int lossy, R
ring_remove(&tail->lru_link);
cache->items--;
cache->available += tail->size;
- cache->sync[channel->common.id] = serial;
- display_channel_push_release(channel, SPICE_RES_TYPE_PIXMAP, tail->id, tail->sync);
+ cache->sync[dcc->common.id] = serial;
+ display_channel_push_release(dcc, SPICE_RES_TYPE_PIXMAP, tail->id, tail->sync);
free(tail);
}
++cache->items;
@@ -143,8 +142,8 @@ static int FUNC_NAME(add)(CACHE *cache, uint64_t id, uint32_t size, int lossy, R
item->size = size;
item->lossy = lossy;
memset(item->sync, 0, sizeof(item->sync));
- item->sync[channel->common.id] = serial;
- cache->sync[channel->common.id] = serial;
+ item->sync[dcc->common.id] = serial;
+ cache->sync[dcc->common.id] = serial;
pthread_mutex_unlock(&cache->lock);
return TRUE;
}
@@ -169,25 +168,24 @@ static void PRIVATE_FUNC_NAME(clear)(CACHE *cache)
cache->items = 0;
}
-static void FUNC_NAME(reset)(CACHE *cache, RedChannelClient *rcc, SpiceMsgWaitForChannels* sync_data)
+static void FUNC_NAME(reset)(CACHE *cache, DisplayChannelClient *dcc, SpiceMsgWaitForChannels* sync_data)
{
- CHANNEL *channel = CHANNEL_FROM_RCC(rcc);
uint8_t wait_count;
uint64_t serial;
uint32_t i;
- serial = red_channel_client_get_message_serial(rcc);
+ serial = red_channel_client_get_message_serial(&dcc->common.base);
pthread_mutex_lock(&cache->lock);
PRIVATE_FUNC_NAME(clear)(cache);
- channel->CACH_GENERATION = ++cache->generation;
- cache->generation_initiator.client = channel->common.id;
+ dcc->CACH_GENERATION = ++cache->generation;
+ cache->generation_initiator.client = dcc->common.id;
cache->generation_initiator.message = serial;
- cache->sync[channel->common.id] = serial;
+ cache->sync[dcc->common.id] = serial;
wait_count = 0;
for (i = 0; i < MAX_CACHE_CLIENTS; i++) {
- if (cache->sync[i] && i != channel->common.id) {
+ if (cache->sync[i] && i != dcc->common.id) {
sync_data->wait_list[wait_count].channel_type = SPICE_CHANNEL_DISPLAY;
sync_data->wait_list[wait_count].channel_id = i;
sync_data->wait_list[wait_count++].message_serial = cache->sync[i];