Esempio n. 1
0
static int cos_net_evt_loop(void)
{
	int alloc_sz = MTU;
	char *data;
	cbuf_t cb;

	assert(event_thd > 0);
	ip_td = parent_tsplit(cos_spd_id(), td_root, "", 0, TOR_ALL, -1);
	assert(ip_td > 0);
	printc("network uc %d starting...\n", cos_get_thd_id());
	alloc_sz = sizeof(struct cos_array) + MTU;
	while (1) {
		int sz;

		data = cbuf_alloc(alloc_sz, &cb);
		assert(data);
		/* printc("tnet_tip_tread (thd %d)\n", cos_get_thd_id()); */
		sz = parent_tread(cos_spd_id(), ip_td, cb, alloc_sz);
		tcp_tread_cnt++;
		assert(sz > 0);
		cos_net_interrupt(data, sz);
		assert(lock_contested(&net_lock) != cos_get_thd_id());
		cbuf_free(data);
	}

	return 0;
}
Esempio n. 2
0
td_t 
tsplit(spdid_t spdid, td_t tid, char *param, int len, 
       tor_flags_t tflags, long evtid)
{
	td_t ret = -ENOMEM, ntd;
	struct torrent *t;

	if (tid != td_root) return -EINVAL;
	ntd = parent_tsplit(cos_spd_id(), tid, param, len, tflags, evtid);
	if (ntd <= 0) ERR_THROW(ntd, err);

	t = tor_alloc((void*)ntd, tflags);
	if (!t) ERR_THROW(-ENOMEM, err);
	ret = t->td;
err:
	return ret;
}