Пример #1
0
Файл: tesc.c Проект: bytemine/ut
/*
 *	tesc_del_reader()
 *
 *	unregisters the reader for 'fd'
 *	and delete the read buffer
 *
 *	returns 0 on success, -1 on error
 */
int tesc_del_reader (const chn_t *ch)
{
int fd = ch->fd;

    if (fd < 0 || fd >= FDMAPSIZ) {
	/* illegal fd */
	return -1;
    }

    if (! schdat.fdio[fd]) {
	/* no fdio */
	return -1;
    }
    if (! schdat.fdio[fd]->rf) {
	/* no reader */
	return -1;
    }

    /* delete the read buffer */
    data_del_buf (schdat.fdio[fd]->rb);

    if (! schdat.fdio[fd]->wq && ! schdat.fdio[fd]->kf) {
	/* remove it from the list of active fdios */
	ring_remove (schdat.fdio[fd]);
	/* delete the fdio structure */
	free (schdat.fdio[fd]);
	schdat.fdio[fd] = 0;
    } else {
	/* reset the reader related fields */
	schdat.fdio[fd]->rb = 0;
	schdat.fdio[fd]->rf = 0;
    }

    return 0;
}
Пример #2
0
static bool image_cache_hit(ImageCache *cache, uint64_t id)
{
    ImageCacheItem *item;
    if (!(item = image_cache_find(cache, id))) {
        return FALSE;
    }
#ifdef IMAGE_CACHE_AGE
    item->age = cache->age;
#endif
    ring_remove(&item->lru_link);
    ring_add(&cache->lru, &item->lru_link);
    return TRUE;
}
Пример #3
0
Файл: tesc.c Проект: bytemine/ut
/*
 *	tesc_del_wq()
 *
 *	delete the write queue for the specified fd (via 'ch')
 *
 *	returns 0 on success, -1 on error
 */
int tesc_del_wq (const chn_t *ch)
{
int fd = ch->fd;
msg_t *cur, *nxt;

    if (fd < 0 || fd >= FDMAPSIZ) {
	/* illegal fd */
	return -1;
    }

    if (! schdat.fdio[fd]) {
	/* we don't even have an fdio */
	return -1;
    }

    /* delete all elements of 'wq' */ 
    cur = schdat.fdio[fd]->wq;
    while (cur) {
	nxt = cur->next;
	free (cur);
	cur = nxt;
    }

    schdat.fdio[fd]->wq = 0;
    schdat.fdio[fd]->wt = 0;
    schdat.fdio[fd]->kf = 0;

    /* if no reader, delete fdio structure (ignore keep flag) */
    if (! schdat.fdio[fd]->rf) {
	if (schdat.fdio[fd]->rb) {
	    /* hey! that must not be */
	    data_del_buf (schdat.fdio[fd]->rb);
	}
	/* remove from list of active fdios */
	ring_remove (schdat.fdio[fd]);
	/* delete the fdio structure */
	free (schdat.fdio[fd]);
	schdat.fdio[fd] = 0;
    }

    return 0;
}
Пример #4
0
static void image_cache_remove(ImageCache *cache, ImageCacheItem *item)
{
    ImageCacheItem **now;

    now = &cache->hash_table[item->id % IMAGE_CACHE_HASH_SIZE];
    for (;;) {
        spice_assert(*now);
        if (*now == item) {
            *now = item->next;
            break;
        }
        now = &(*now)->next;
    }
    ring_remove(&item->lru_link);
    pixman_image_unref(item->image);
    free(item);
#ifndef IMAGE_CACHE_AGE
    cache->num_items--;
#endif
}
Пример #5
0
void red_dispatcher_async_complete(struct RedDispatcher *dispatcher,
                                   AsyncCommand *async_command)
{
    pthread_mutex_lock(&dispatcher->async_lock);
    ring_remove(&async_command->link);
    spice_debug("%p: cookie %" PRId64, async_command, async_command->cookie);
    if (ring_is_empty(&dispatcher->async_commands)) {
        spice_debug("no more async commands");
    }
    pthread_mutex_unlock(&dispatcher->async_lock);
    switch (async_command->message) {
    case RED_WORKER_MESSAGE_UPDATE_ASYNC:
        break;
    case RED_WORKER_MESSAGE_ADD_MEMSLOT_ASYNC:
        break;
    case RED_WORKER_MESSAGE_DESTROY_SURFACES_ASYNC:
        break;
    case RED_WORKER_MESSAGE_CREATE_PRIMARY_SURFACE_ASYNC:
        red_dispatcher_create_primary_surface_complete(dispatcher);
        break;
    case RED_WORKER_MESSAGE_DESTROY_PRIMARY_SURFACE_ASYNC:
        red_dispatcher_destroy_primary_surface_complete(dispatcher);
        break;
    case RED_WORKER_MESSAGE_DESTROY_SURFACE_WAIT_ASYNC:
        break;
    case RED_WORKER_MESSAGE_FLUSH_SURFACES_ASYNC:
        break;
    case RED_WORKER_MESSAGE_MONITORS_CONFIG_ASYNC:
        break;
    default:
        spice_warning("unexpected message %d", async_command->message);
    }
    dispatcher->qxl->st->qif->async_complete(dispatcher->qxl,
                                             async_command->cookie);
    free(async_command);
}