server/red_worker: introduce CommonChannel

with everything (almost) not in red_channel's RedChannel

As a result of CommonChannel a free cb is added to EventHandler,
to take care of non zero offset for embedded EventHandler.
This commit is contained in:
Alon Levy 2010-11-07 14:05:19 +02:00
parent 9330dbac13
commit e8698ea0f8
3 changed files with 222 additions and 182 deletions

View File

@ -74,7 +74,7 @@ static void FUNC_NAME(remove)(CHANNEL *channel, CacheItem *item)
channel->VAR_NAME(available) += item->size;
red_pipe_item_init(&item->u.pipe_data, PIPE_ITEM_TYPE_INVAL_ONE);
red_pipe_add_tail(&channel->base, &item->u.pipe_data); // for now
red_pipe_add_tail(&channel->common.base, &item->u.pipe_data); // for now
}
static int FUNC_NAME(add)(CHANNEL *channel, uint64_t id, size_t size)

View File

@ -48,9 +48,9 @@ static int FUNC_NAME(hit)(CACHE *cache, uint64_t id, int *lossy, CHANNEL *channe
if (item->id == id) {
ring_remove(&item->lru_link);
ring_add(&cache->lru, &item->lru_link);
ASSERT(channel->base.id < MAX_CACHE_CLIENTS)
item->sync[channel->base.id] = serial;
cache->sync[channel->base.id] = serial;
ASSERT(channel->common.id < MAX_CACHE_CLIENTS)
item->sync[channel->common.id] = serial;
cache->sync[channel->common.id] = serial;
*lossy = item->lossy;
break;
}
@ -108,7 +108,7 @@ static int FUNC_NAME(add)(CACHE *cache, uint64_t id, uint32_t size, int lossy, C
NewCacheItem **now;
if (!(tail = (NewCacheItem *)ring_get_tail(&cache->lru)) ||
tail->sync[channel->base.id] == serial) {
tail->sync[channel->common.id] == serial) {
cache->available += size;
pthread_mutex_unlock(&cache->lock);
free(item);
@ -127,7 +127,7 @@ static int FUNC_NAME(add)(CACHE *cache, uint64_t id, uint32_t size, int lossy, C
ring_remove(&tail->lru_link);
cache->items--;
cache->available += tail->size;
cache->sync[channel->base.id] = serial;
cache->sync[channel->common.id] = serial;
display_channel_push_release(channel, SPICE_RES_TYPE_PIXMAP, tail->id, tail->sync);
free(tail);
}
@ -140,8 +140,8 @@ static int FUNC_NAME(add)(CACHE *cache, uint64_t id, uint32_t size, int lossy, C
item->size = size;
item->lossy = lossy;
memset(item->sync, 0, sizeof(item->sync));
item->sync[channel->base.id] = serial;
cache->sync[channel->base.id] = serial;
item->sync[channel->common.id] = serial;
cache->sync[channel->common.id] = serial;
pthread_mutex_unlock(&cache->lock);
return TRUE;
}
@ -177,13 +177,13 @@ static void FUNC_NAME(reset)(CACHE *cache, CHANNEL *channel, SpiceMsgWaitForChan
PRIVATE_FUNC_NAME(clear)(cache);
channel->CACH_GENERATION = ++cache->generation;
cache->generation_initiator.client = channel->base.id;
cache->generation_initiator.client = channel->common.id;
cache->generation_initiator.message = serial;
cache->sync[channel->base.id] = serial;
cache->sync[channel->common.id] = serial;
wait_count = 0;
for (i = 0; i < MAX_CACHE_CLIENTS; i++) {
if (cache->sync[i] && i != channel->base.id) {
if (cache->sync[i] && i != channel->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];

File diff suppressed because it is too large Load Diff