Example #1
0
static void
mgr_remove_client_mem(struct spd_tmem_info *sti, struct cos_cbuf_item *cci)
{
	__cbuf_c_delete(sti, cci->desc.cbid, &cci->desc);
	/* DOUT("after buf del before map del\n"); */
	cos_map_del(&cb_ids, cci->desc.cbid);

	DOUT("fly..........cbid is %d\n", cci->desc.cbid);

	cci->desc.cbid = 0;
	cci->parent_spdid = 0;

	// Clear our memory to prevent leakage
	memset(cci->desc.addr, 0, PAGE_SIZE);
	/* printc("Removing from local list\n"); */

	REM_LIST(cci, next, prev);

	/* TODO: move all of this into the tmem generic code just like the ++s */
	sti->num_allocated--;
	if (sti->num_allocated == 0) empty_comps++;

	if (sti->num_allocated >= sti->num_desired) over_quota_total--;
	assert(sti->num_allocated == tmem_num_alloc_tmems(sti->spdid));
}
Example #2
0
/* will not deallocate ->data */
void
tor_free(struct torrent *t)
{
	assert(t);
	if (cos_map_del(&torrents, t->td)) BUG();
	free(t);
}
static inline void call_desc_dealloc(struct desc_track *desc) {
	assert(desc);
	int id = desc->IDL_id;
	desc->IDL_server_id = -1;  // reset to -1
	assert(desc);
	cslab_free_IDL_service_slab(desc);
	cos_map_del(&IDL_service_desc_maps, id);
	return;
}
Example #4
0
static inline void net_conn_free(struct intern_connection *ic)
{
	assert(ic);
	assert(0 == ic->incoming_size);

	cos_map_del(&connections, net_conn_get_opaque(ic));
	free(ic);

	return;
}
static void
rdlk_dealloc(int id)
{
	assert(id >= 0);
	struct rec_data_lk *rd;
	rd = rdlk_lookup(id);
	assert(rd);
	cslab_free_rdlk(rd);
	cos_map_del(&uniq_lkids, id);
	return;
}
static void
map_rd_delete(td_t tid)
{
    assert(tid >= 0);
    struct rec_data_tor *rd;
    rd = map_rd_lookup(tid);
    assert(rd && rd->param);
    free(rd->param);   // free the memory for the path name saving
    cslab_free_rd(rd);
    cos_map_del(&uniq_tids, tid);
    return;
}
int content_remove(spdid_t spdid, long conn_id)
{
	struct connection *c = cos_map_lookup(&conn_map, conn_id);

	if (NULL == c) return 1;
	cos_map_del(&conn_map, c->conn_id);
	c->conn_id = -1;
	http_free_connection(c);

	/* bookkeeping */
	http_conn_cnt++;

	return 0;
}
Example #8
0
static void mapping_free(long extern_evt)
{
	if (cos_map_del(&evt_map, extern_evt)) BUG();
}
Example #9
0
int
cbuf_c_create(spdid_t spdid, int size, long cbid)
{
	int ret = -1;
	void *v;
	struct spd_tmem_info *sti;
	struct cos_cbuf_item *cbuf_item;
	struct cb_desc *d;

	union cbuf_meta *mc = NULL;

	/* DOUT("thd: %d spd: %d cbuf_c_create is called here!!\n", cos_get_thd_id(), spdid); */
	/* DOUT("passed cbid is %ld\n",cbid); */
	TAKE();

	sti = get_spd_info(spdid);
	
	/* Make sure we have access to the component shared page */
	assert(SPD_IS_MANAGED(sti));
	assert(cbid >= 0);

	if (cbid) {
		 // vector should already exist
		v = cos_map_lookup(&cb_ids, cbid);
		if (unlikely((spdid_t)(int)v != spdid)) goto err;
 	} else {
		cbid = cos_map_add(&cb_ids, (void *)(unsigned long)spdid);
		if ((mc = __spd_cbvect_lookup_range(sti, (cbid))) == NULL){
			RELEASE();
			return cbid*-1;	
		} 
	}
	cos_map_del(&cb_ids, cbid);
	cbuf_item = tmem_grant(sti);
	assert(cbuf_item);

	d             = &cbuf_item->desc;
	d->principal  = cos_get_thd_id();
	d->obj_sz     = PAGE_SIZE;
	d->owner.spd  = sti->spdid;
	d->owner.cbd  = d;

	/* Jiguo:
	  This can be two different cases:
	  1. A local cached one is returned with a cbid
	  2. A cbuf item is obtained from the global free list without cbid
	 */
	DOUT("d->cbid is %d\n",d->cbid);
	if (d->cbid == 0) {
		INIT_LIST(&d->owner, next, prev);  // only created when first time
		cbid = cos_map_add(&cb_ids, d);    // we use a new cbuf
		DOUT("new cbid is %ld\n",cbid);
	} else {
		cbid = cbuf_item->desc.cbid;       // use a local cached one
		DOUT("cached cbid is %ld\n",cbid);
	}

	DOUT("cbuf_create:::new cbid is %ld\n",cbid);
	ret = d->cbid = cbid;

	mc = __spd_cbvect_lookup_range(sti, cbid);
	assert(mc);
	cbuf_item->entry = mc;

	mc->c.ptr     = d->owner.addr >> PAGE_ORDER;
	mc->c.obj_sz  = ((unsigned int)PAGE_SIZE) >> CBUF_OBJ_SZ_SHIFT;
	mc->c_0.th_id = cos_get_thd_id();
	mc->c.flags  |= CBUFM_IN_USE | CBUFM_TOUCHED;
done:
	RELEASE();
	return ret;
err:
	ret = -1;
	goto done;
}