Ejemplo n.º 1
0
/* Store a bitmap in the cache */
void
cache_put_bitmap(rdcConnection conn, uint8 id, uint16 idx, HBITMAP bitmap)
{
	HBITMAP old;

	if ((id < NUM_ELEMENTS(conn->bmpcache)) && (idx < NUM_ELEMENTS(conn->bmpcache[0])))
	{
		old = conn->bmpcache[id][idx].bitmap;
		if (old != NULL)
			ui_destroy_bitmap(old);
		conn->bmpcache[id][idx].bitmap = bitmap;
				
		if (IS_PERSISTENT(id))
		{
			if (old == NULL)
				conn->bmpcache[id][idx].previous = conn->bmpcache[id][idx].next = NOT_SET;

			cache_bump_bitmap(conn, id, idx, TO_TOP);
			if (conn->bmpcacheCount[id] > BMPCACHE2_C2_CELLS)
				cache_evict_bitmap(conn, id);
		}
	}
	else if ((id < NUM_ELEMENTS(conn->volatileBc)) && (idx == 0x7fff))
	{
		old = conn->volatileBc[id];
		if (old != NULL)
			ui_destroy_bitmap(old);
		conn->volatileBc[id] = bitmap;
	}
	else
	{
		error("put bitmap %d:%d\n", id, idx);
	}
}
Ejemplo n.º 2
0
/* Store a bitmap in the cache */
void
cache_put_bitmap(uint8 id, uint16 idx, RD_HBITMAP bitmap)
{
	RD_HBITMAP old;

	if ((id < NUM_ELEMENTS(g_bmpcache)) && (idx < NUM_ELEMENTS(g_bmpcache[0])))
	{
		old = g_bmpcache[id][idx].bitmap;
		if (old != NULL)
			ui_destroy_bitmap(old);
		g_bmpcache[id][idx].bitmap = bitmap;

		if (IS_PERSISTENT(id))
		{
			if (old == NULL)
				g_bmpcache[id][idx].previous = g_bmpcache[id][idx].next = NOT_SET;

			cache_bump_bitmap(id, idx, TO_TOP);
			if (g_bmpcache_count[id] > BMPCACHE2_C2_CELLS)
				cache_evict_bitmap(id);
		}
	}
	else if ((id < NUM_ELEMENTS(g_volatile_bc)) && (idx == 0x7fff))
	{
		old = g_volatile_bc[id];
		if (old != NULL)
			ui_destroy_bitmap(old);
		g_volatile_bc[id] = bitmap;
	}
	else
	{
		error("put bitmap %d:%d\n", id, idx);
	}
}
Ejemplo n.º 3
0
/* Load a bitmap from the persistent cache */
RDCBOOL
pstcache_load_bitmap(rdcConnection conn, uint8 cache_id, uint16 cache_idx)
{
	uint8 *celldata;
	int fd;
	CELLHEADER cellhdr;
	HBITMAP bitmap;

	if (!conn->bitmapCachePersist)
		return False;

	if (!IS_PERSISTENT(cache_id) || cache_idx >= BMPCACHE2_NUM_PSTCELLS)
		return False;

	fd = conn->pstcacheFd[cache_id];
	rd_lseek_file(fd, cache_idx * (conn->pstcacheBpp * MAX_CELL_SIZE + sizeof(CELLHEADER)));
	rd_read_file(fd, &cellhdr, sizeof(CELLHEADER));
	celldata = (uint8 *) xmalloc(cellhdr.length);
	rd_read_file(fd, celldata, cellhdr.length);

	bitmap = ui_create_bitmap(conn, cellhdr.width, cellhdr.height, celldata);
	DEBUG(("Load bitmap from disk: id=%d, idx=%d, bmp=0x%x)\n", cache_id, cache_idx, bitmap));
	cache_put_bitmap(conn, cache_id, cache_idx, bitmap);

	xfree(celldata);
	return True;
}
Ejemplo n.º 4
0
/* Load a bitmap from the persistent cache */
BOOL
pstcache_load_bitmap(RDPCLIENT * This, uint8 cache_id, uint16 cache_idx)
{
	uint8 *celldata;
	int fd;
	CELLHEADER cellhdr;
	HBITMAP bitmap;

	if (!This->bitmap_cache_persist_enable)
		return False;

	if (!IS_PERSISTENT(cache_id) || cache_idx >= BMPCACHE2_NUM_PSTCELLS)
		return False;

	fd = This->pstcache_fd[cache_id];
	rd_lseek_file(fd, cache_idx * (This->pstcache_Bpp * MAX_CELL_SIZE + sizeof(CELLHEADER)));
	rd_read_file(fd, &cellhdr, sizeof(CELLHEADER));
	celldata = (uint8 *) malloc(cellhdr.length);

	if(celldata == NULL)
		return False;

	rd_read_file(fd, celldata, cellhdr.length);

	bitmap = ui_create_bitmap(This, cellhdr.width, cellhdr.height, celldata);
	DEBUG(("Load bitmap from disk: id=%d, idx=%d, bmp=0x%x)\n", cache_id, cache_idx, bitmap));
	cache_put_bitmap(This, cache_id, cache_idx, bitmap);

	free(celldata);
	return True;
}
Ejemplo n.º 5
0
/* Load a bitmap from the persistent cache */
RD_BOOL
pstcache_load_bitmap(rdpPcache * pcache, uint8 cache_id, uint16 cache_idx)
{
	uint8 *celldata;
	int fd;
	CELLHEADER cellhdr;
	RD_HBITMAP bitmap;

	if (!(pcache->rdp->settings->bitmap_cache_persist_enable))
		return False;

	if (!IS_PERSISTENT(cache_id) || cache_idx >= BMPCACHE2_NUM_PSTCELLS)
		return False;

	fd = pcache->pstcache_fd[cache_id];
	rd_lseek_file(fd, cache_idx *
			(pcache->pstcache_Bpp * MAX_CELL_SIZE + sizeof(CELLHEADER)));
	rd_read_file(fd, &cellhdr, sizeof(CELLHEADER));
	celldata = (uint8 *) xmalloc(cellhdr.length);
	rd_read_file(fd, celldata, cellhdr.length);

	bitmap = ui_create_bitmap(pcache->rdp->inst, cellhdr.width, cellhdr.height, celldata);
	DEBUG("Load bitmap from disk: id=%d, idx=%d, bmp=0x%x)\n", cache_id, cache_idx,
	       (unsigned int) bitmap);
	cache_put_bitmap(pcache->rdp->cache, cache_id, cache_idx, bitmap);

	xfree(celldata);
	return True;
}
Ejemplo n.º 6
0
/* Load a bitmap from the persistent cache */
RD_BOOL
pstcache_load_bitmap(uint8 cache_id, uint16 cache_idx)
{
	uint8 *celldata;
	int fd;
	CELLHEADER cellhdr;
	RD_HBITMAP bitmap;

	if (!g_bitmap_cache_persist_enable)
		return False;

	if (!IS_PERSISTENT(cache_id) || cache_idx >= BMPCACHE2_NUM_PSTCELLS)
		return False;

	fd = g_pstcache_fd[cache_id];
	rd_lseek_file(fd, cache_idx * (g_pstcache_Bpp * MAX_CELL_SIZE + sizeof(CELLHEADER)));
	rd_read_file(fd, &cellhdr, sizeof(CELLHEADER));
	celldata = (uint8 *) xmalloc(cellhdr.length);
	rd_read_file(fd, celldata, cellhdr.length);

	bitmap = ui_create_bitmap(cellhdr.width, cellhdr.height, celldata);
	logger(Core, Debug, "pstcache_load_bitmap(), load bitmap from disk: id=%d, idx=%d, bmp=%p)",
	       cache_id, cache_idx, bitmap);
	cache_put_bitmap(cache_id, cache_idx, bitmap);

	xfree(celldata);
	return True;
}
Ejemplo n.º 7
0
/* List the bitmap keys from the persistent cache file */
int
pstcache_enumerate(rdpPcache * pcache, uint8 id, HASH_KEY * keylist)
{
	int fd, n;
	uint16 idx;
	sint16 mru_idx[0xa00];
	uint32 mru_stamp[0xa00];
	CELLHEADER cellhdr;

	if (!(pcache->rdp->settings->bitmap_cache &&
	      pcache->rdp->settings->bitmap_cache_persist_enable &&
	      IS_PERSISTENT(id)))
		return 0;

	/* The server disconnects if the bitmap cache content is sent more than once */
	if (pcache->pstcache_enumerated)
		return 0;

	DEBUG_RDP5("Persistent bitmap cache enumeration... ");
	for (idx = 0; idx < BMPCACHE2_NUM_PSTCELLS; idx++)
	{
		fd = pcache->pstcache_fd[id];
		rd_lseek_file(fd, idx *
			(pcache->pstcache_Bpp * MAX_CELL_SIZE + sizeof(CELLHEADER)));
		if (rd_read_file(fd, &cellhdr, sizeof(CELLHEADER)) <= 0)
			break;

		if (memcmp(cellhdr.key, pcache->zero_key, sizeof(HASH_KEY)) != 0)
		{
			memcpy(keylist[idx], cellhdr.key, sizeof(HASH_KEY));

			/* Pre-cache (not possible for 8 bit color depth cause it needs a colormap) */
			if (pcache->rdp->settings->bitmap_cache_precache && cellhdr.stamp &&
			    pcache->rdp->settings->server_depth > 8)
				pstcache_load_bitmap(pcache, id, idx);

			/* Sort by stamp */
			for (n = idx; n > 0 && cellhdr.stamp < mru_stamp[n - 1]; n--)
			{
				mru_idx[n] = mru_idx[n - 1];
				mru_stamp[n] = mru_stamp[n - 1];
			}

			mru_idx[n] = idx;
			mru_stamp[n] = cellhdr.stamp;
		}
		else
		{
			break;
		}
	}

	DEBUG_RDP5("%d cached bitmaps.\n", idx);

	cache_rebuild_bmpcache_linked_list(pcache->rdp->cache, id, mru_idx, idx);
	pcache->pstcache_enumerated = True;
	return idx;
}
Ejemplo n.º 8
0
/* List the bitmap keys from the persistent cache file */
int
pstcache_enumerate(uint8 id, HASH_KEY * keylist)
{
	int fd, n;
	uint16 idx;
	sint16 mru_idx[0xa00];
	uint32 mru_stamp[0xa00];
	CELLHEADER cellhdr;

	if (!(g_bitmap_cache && g_bitmap_cache_persist_enable && IS_PERSISTENT(id)))
		return 0;

	/* The server disconnects if the bitmap cache content is sent more than once */
	if (g_pstcache_enumerated)
		return 0;

	logger(Core, Debug, "pstcache_enumerate(), start enumeration");
	for (idx = 0; idx < BMPCACHE2_NUM_PSTCELLS; idx++)
	{
		fd = g_pstcache_fd[id];
		rd_lseek_file(fd, idx * (g_pstcache_Bpp * MAX_CELL_SIZE + sizeof(CELLHEADER)));
		if (rd_read_file(fd, &cellhdr, sizeof(CELLHEADER)) <= 0)
			break;

		if (memcmp(cellhdr.key, zero_key, sizeof(HASH_KEY)) != 0)
		{
			memcpy(keylist[idx], cellhdr.key, sizeof(HASH_KEY));

			/* Pre-cache (not possible for 8-bit colour depth cause it needs a colourmap) */
			if (g_bitmap_cache_precache && cellhdr.stamp && g_server_depth > 8)
				pstcache_load_bitmap(id, idx);

			/* Sort by stamp */
			for (n = idx; n > 0 && cellhdr.stamp < mru_stamp[n - 1]; n--)
			{
				mru_idx[n] = mru_idx[n - 1];
				mru_stamp[n] = mru_stamp[n - 1];
			}

			mru_idx[n] = idx;
			mru_stamp[n] = cellhdr.stamp;
		}
		else
		{
			break;
		}
	}

	logger(Core, Debug, "pstcache_enumerate(), %d cached bitmaps", idx);

	cache_rebuild_bmpcache_linked_list(id, mru_idx, idx);
	g_pstcache_enumerated = True;
	return idx;
}
Ejemplo n.º 9
0
/* Update mru stamp/index for a bitmap */
void
pstcache_touch_bitmap(rdcConnection conn, uint8 cache_id, uint16 cache_idx, uint32 stamp)
{
	int fd;

	if (!IS_PERSISTENT(cache_id) || cache_idx >= BMPCACHE2_NUM_PSTCELLS)
		return;

	fd = conn->pstcacheFd[cache_id];
	rd_lseek_file(fd, 12 + cache_idx * (conn->pstcacheBpp * MAX_CELL_SIZE + sizeof(CELLHEADER)));
	rd_write_file(fd, &stamp, sizeof(stamp));
}
Ejemplo n.º 10
0
/* Update mru stamp/index for a bitmap */
void
pstcache_touch_bitmap(RDPCLIENT * This, uint8 cache_id, uint16 cache_idx, uint32 stamp)
{
	int fd;

	if (!IS_PERSISTENT(cache_id) || cache_idx >= BMPCACHE2_NUM_PSTCELLS)
		return;

	fd = This->pstcache_fd[cache_id];
	rd_lseek_file(fd, 12 + cache_idx * (This->pstcache_Bpp * MAX_CELL_SIZE + sizeof(CELLHEADER)));
	rd_write_file(fd, &stamp, sizeof(stamp));
}
Ejemplo n.º 11
0
/* List the bitmap keys from the persistent cache file */
int
pstcache_enumerate(rdcConnection conn, uint8 id, HASH_KEY * keylist)
{
	int fd, idx, n;
	sint16 mru_idx[0xa00];
	uint32 mru_stamp[0xa00];
	CELLHEADER cellhdr;

	if (!(conn->bitmapCache && conn->bitmapCachePersist && IS_PERSISTENT(id)))
		return 0;

	/* The server disconnects if the bitmap cache content is sent more than once */
	if (conn->pstcacheEnumerated)
		return 0;

	DEBUG_RDP5(("Persistent bitmap cache enumeration... "));
	for (idx = 0; idx < BMPCACHE2_NUM_PSTCELLS; idx++)
	{
		fd = conn->pstcacheFd[id];
		rd_lseek_file(fd, idx * (conn->pstcacheBpp * MAX_CELL_SIZE + sizeof(CELLHEADER)));
		if (rd_read_file(fd, &cellhdr, sizeof(CELLHEADER)) <= 0)
			break;

		if (memcmp(cellhdr.key, zero_key, sizeof(HASH_KEY)) != 0)
		{
			memcpy(keylist[idx], cellhdr.key, sizeof(HASH_KEY));

			/* Pre-cache (not possible for 8bpp because 8bpp needs a colourmap) */
			if (conn->bitmapCachePrecache && cellhdr.stamp && conn->serverBpp > 8)
				pstcache_load_bitmap(conn, id, idx);

			/* Sort by stamp */
			for (n = idx; n > 0 && cellhdr.stamp < mru_stamp[n - 1]; n--)
			{
				mru_idx[n] = mru_idx[n - 1];
				mru_stamp[n] = mru_stamp[n - 1];
			}

			mru_idx[n] = idx;
			mru_stamp[n] = cellhdr.stamp;
		}
		else
		{
			break;
		}
	}

	DEBUG_RDP5(("%d cached bitmaps.\n", idx));

	cache_rebuild_bmpcache_linked_list(conn, id, mru_idx, idx);
	conn->pstcacheEnumerated = True;
	return idx;
}
Ejemplo n.º 12
0
/* Updates the persistent bitmap cache MRU information on exit */
void
cache_save_state(void)
{
	uint32 id = 0, t = 0;
	int idx;

	for (id = 0; id < NUM_ELEMENTS(g_bmpcache); id++)
		if (IS_PERSISTENT(id))
		{
			DEBUG_RDP5(("Saving cache state for bitmap cache %d...", id));
			idx = g_bmpcache_lru[id];
			while (idx >= 0)
			{
				pstcache_touch_bitmap((uint8) id, (uint16) idx, ++t);
				idx = g_bmpcache[id][idx].next;
			}
			DEBUG_RDP5((" %d stamps written.\n", t));
		}
}
Ejemplo n.º 13
0
/* Updates the persistent bitmap cache MRU information on exit */
void
cache_save_state(rdcConnection conn)
{
	uint32 id = 0, t = 0;
	int idx;

	for (id = 0; id < NUM_ELEMENTS(conn->bmpcache); id++)
		if (IS_PERSISTENT(id))
		{
			DEBUG_RDP5(("Saving cache state for bitmap cache %d...", id));
			idx = conn->bmpcacheLru[id];
			while (idx >= 0)
			{
				pstcache_touch_bitmap(conn, id, idx, ++t);
				idx = conn->bmpcache[id][idx].next;
			}
			DEBUG_RDP5((" %d stamps written.\n", t));
		}
}
Ejemplo n.º 14
0
/* Retrieve a bitmap from the cache */
RD_HBITMAP
cache_get_bitmap(uint8 id, uint16 idx)
{
	if ((id < NUM_ELEMENTS(g_bmpcache)) && (idx < NUM_ELEMENTS(g_bmpcache[0])))
	{
		if (g_bmpcache[id][idx].bitmap || pstcache_load_bitmap(id, idx))
		{
			if (IS_PERSISTENT(id))
				cache_bump_bitmap(id, idx, BUMP_COUNT);

			return g_bmpcache[id][idx].bitmap;
		}
	}
	else if ((id < NUM_ELEMENTS(g_volatile_bc)) && (idx == 0x7fff))
	{
		return g_volatile_bc[id];
	}

	error("get bitmap %d:%d\n", id, idx);
	return NULL;
}
Ejemplo n.º 15
0
/* Retrieve a bitmap from the cache */
HBITMAP
cache_get_bitmap(rdcConnection conn, uint8 id, uint16 idx)
{
	if ((id < NUM_ELEMENTS(conn->bmpcache)) && (idx < NUM_ELEMENTS(conn->bmpcache[0])))
	{
		if (conn->bmpcache[id][idx].bitmap || pstcache_load_bitmap(conn, id, idx))
		{
			if (IS_PERSISTENT(id))
				cache_bump_bitmap(conn, id, idx, BUMP_COUNT);

			return conn->bmpcache[id][idx].bitmap;
		}
	}
	else if ((id < NUM_ELEMENTS(conn->volatileBc)) && (idx == 0x7fff))
	{
		return conn->volatileBc[id];
	}

	error("get bitmap %d:%d\n", id, idx);
	return NULL;
}
Ejemplo n.º 16
0
/* Store a bitmap in the persistent cache */
BOOL
pstcache_save_bitmap(RDPCLIENT * This, uint8 cache_id, uint16 cache_idx, uint8 * key,
		     uint8 width, uint8 height, uint16 length, uint8 * data)
{
	int fd;
	CELLHEADER cellhdr;

	if (!IS_PERSISTENT(cache_id) || cache_idx >= BMPCACHE2_NUM_PSTCELLS)
		return False;

	memcpy(cellhdr.key, key, sizeof(HASH_KEY));
	cellhdr.width = width;
	cellhdr.height = height;
	cellhdr.length = length;
	cellhdr.stamp = 0;

	fd = This->pstcache_fd[cache_id];
	rd_lseek_file(fd, cache_idx * (This->pstcache_Bpp * MAX_CELL_SIZE + sizeof(CELLHEADER)));
	rd_write_file(fd, &cellhdr, sizeof(CELLHEADER));
	rd_write_file(fd, data, length);

	return True;
}
Ejemplo n.º 17
0
/* Evict the least-recently used bitmap from the cache */
void
cache_evict_bitmap(RDPCLIENT * This, uint8 id)
{
	uint16 idx;
	int n_idx;

	if (!IS_PERSISTENT(id))
		return;

	idx = This->cache.bmpcache_lru[id];
	n_idx = This->cache.bmpcache[id][idx].next;
	DEBUG_RDP5(("evict bitmap: id=%d idx=%d n_idx=%d bmp=0x%x\n", id, idx, n_idx,
		    This->cache.bmpcache[id][idx].bitmap));

	ui_destroy_bitmap(This, This->cache.bmpcache[id][idx].bitmap);
	--This->cache.bmpcache_count[id];
	This->cache.bmpcache[id][idx].bitmap = 0;

	This->cache.bmpcache_lru[id] = n_idx;
	This->cache.bmpcache[id][n_idx].previous = NOT_SET;

	pstcache_touch_bitmap(This, id, idx, 0);
}
Ejemplo n.º 18
0
/* Evict the least-recently used bitmap from the cache */
static void
cache_evict_bitmap(rdcConnection conn, uint8 id)
{
	uint16 idx;
	int n_idx;

	if (!IS_PERSISTENT(id))
		return;

	idx = conn->bmpcacheLru[id];
	n_idx = conn->bmpcache[id][idx].next;
	DEBUG_RDP5(("evict bitmap: id=%d idx=%d n_idx=%d bmp=0x%x\n", id, idx, n_idx,
		    conn->bmpcache[id][idx].bitmap));

	ui_destroy_bitmap(conn->bmpcache[id][idx].bitmap);
	--conn->bmpcacheCount[id];
	conn->bmpcache[id][idx].bitmap = 0;

	conn->bmpcacheLru[id] = n_idx;
	conn->bmpcache[id][n_idx].previous = NOT_SET;

	pstcache_touch_bitmap(conn, id, idx, 0);
}
Ejemplo n.º 19
0
/* Evict the least-recently used bitmap from the cache */
void
cache_evict_bitmap(uint8 id)
{
	uint16 idx;
	int n_idx;

	if (!IS_PERSISTENT(id))
		return;

	idx = g_bmpcache_lru[id];
	n_idx = g_bmpcache[id][idx].next;
	DEBUG_RDP5(("evict bitmap: id=%d idx=%d n_idx=%d bmp=0x%x\n", id, idx, n_idx,
		    g_bmpcache[id][idx].bitmap));

	ui_destroy_bitmap(g_bmpcache[id][idx].bitmap);
	--g_bmpcache_count[id];
	g_bmpcache[id][idx].bitmap = 0;

	g_bmpcache_lru[id] = n_idx;
	g_bmpcache[id][n_idx].previous = NOT_SET;

	pstcache_touch_bitmap(id, idx, 0);
}
Ejemplo n.º 20
0
/* Move a bitmap to a new position in the linked list. */
void
cache_bump_bitmap(uint8 id, uint16 idx, int bump)
{
	int p_idx, n_idx, n;

	if (!IS_PERSISTENT(id))
		return;

	if (g_bmpcache_mru[id] == idx)
		return;

	DEBUG_RDP5(("bump bitmap: id=%d, idx=%d, bump=%d\n", id, idx, bump));

	n_idx = g_bmpcache[id][idx].next;
	p_idx = g_bmpcache[id][idx].previous;

	if (IS_SET(n_idx))
	{
		/* remove */
		--g_bmpcache_count[id];
		if (IS_SET(p_idx))
			g_bmpcache[id][p_idx].next = n_idx;
		else
			g_bmpcache_lru[id] = n_idx;
		if (IS_SET(n_idx))
			g_bmpcache[id][n_idx].previous = p_idx;
		else
			g_bmpcache_mru[id] = p_idx;
	}
	else
	{
		p_idx = NOT_SET;
		n_idx = g_bmpcache_lru[id];
	}

	if (bump >= 0)
	{
		for (n = 0; n < bump && IS_SET(n_idx); n++)
		{
			p_idx = n_idx;
			n_idx = g_bmpcache[id][p_idx].next;
		}
	}
	else
	{
		p_idx = g_bmpcache_mru[id];
		n_idx = NOT_SET;
	}

	/* insert */
	++g_bmpcache_count[id];
	g_bmpcache[id][idx].previous = p_idx;
	g_bmpcache[id][idx].next = n_idx;

	if (p_idx >= 0)
		g_bmpcache[id][p_idx].next = idx;
	else
		g_bmpcache_lru[id] = idx;

	if (n_idx >= 0)
		g_bmpcache[id][n_idx].previous = idx;
	else
		g_bmpcache_mru[id] = idx;
}
Ejemplo n.º 21
0
/* Move a bitmap to a new position in the linked list. */
static void
cache_bump_bitmap(rdcConnection conn, uint8 id, uint16 idx, int bump)
{
	int p_idx, n_idx, n;

	if (!IS_PERSISTENT(id))
		return;

	if (conn->bmpcacheMru[id] == idx)
		return;

	DEBUG_RDP5(("bump bitmap: id=%d, idx=%d, bump=%d\n", id, idx, bump));

	n_idx = conn->bmpcache[id][idx].next;
	p_idx = conn->bmpcache[id][idx].previous;

	if (CACHE_IS_SET(n_idx))
	{
		/* remove */
		--conn->bmpcacheCount[id];
		if (CACHE_IS_SET(p_idx))
			conn->bmpcache[id][p_idx].next = n_idx;
		else
			conn->bmpcacheLru[id] = n_idx;
		if (CACHE_IS_SET(n_idx))
			conn->bmpcache[id][n_idx].previous = p_idx;
		else
			conn->bmpcacheMru[id] = p_idx;
	}
	else
	{
		p_idx = NOT_SET;
		n_idx = conn->bmpcacheLru[id];
	}

	if (bump >= 0)
	{
		for (n = 0; n < bump && CACHE_IS_SET(n_idx); n++)
		{
			p_idx = n_idx;
			n_idx = conn->bmpcache[id][p_idx].next;
		}
	}
	else
	{
		p_idx = conn->bmpcacheMru[id];
		n_idx = NOT_SET;
	}

	/* insert */
	++conn->bmpcacheCount[id];
	conn->bmpcache[id][idx].previous = p_idx;
	conn->bmpcache[id][idx].next = n_idx;

	if (p_idx >= 0)
		conn->bmpcache[id][p_idx].next = idx;
	else
		conn->bmpcacheLru[id] = idx;

	if (n_idx >= 0)
		conn->bmpcache[id][n_idx].previous = idx;
	else
		conn->bmpcacheMru[id] = idx;
}