コード例 #1
0
ファイル: tar.c プロジェクト: gparmer/Composite
int 
cos_init(void)
{
	char *tar_file;
	int tar_sz, tot = 0;

	lock_static_init(&fs_lock);
	torlib_init();

	fs_init_root(&root);
	root_torrent.data = &root;
	root.flags = TOR_READ | TOR_SPLIT;
	
	/* FIXME: should map in the tar file rather than copy it. */
	tar_sz = initf_size();
	tar_file = malloc(tar_sz);
	if (!tar_file) {
		printc("Tar file of size %d cannot be read\n", tar_sz);
		return -1;
	}
	while (tot < tar_sz) tot += initf_read(tot, &tar_file[tot], tar_sz-tot);
	tar_parse_file(tar_file, &root);

	return 0;
}
コード例 #2
0
ファイル: netif.c プロジェクト: wittrock/Composite
static int init(void) 
{
	unsigned short int i;
	void *b;

	lock_static_init(&netif_lock);

	NET_LOCK_TAKE();

	cos_vect_init_static(&tmap);
	
	rb_init(&rb1_md_wildcard, &rb1);
	rb_init(&rb2_md, &rb2);
	/* Setup the region from which headers will be transmitted. */
	if (cos_buff_mgmt(COS_BM_XMIT_REGION, &xmit_headers, sizeof(xmit_headers), 0)) {
		prints("net: error setting up xmit region.");
	}
	/* Wildcard upcall */
	if (cos_net_create_net_brand(0, &rb1_md_wildcard)) BUG();
	for (i = 0 ; i < NUM_WILDCARD_BUFFS ; i++) {
		if(!(b = alloc_rb_buff(&rb1_md_wildcard))) {
			prints("net: could not allocate the ring buffer.");
		}
		if(rb_add_buff(&rb1_md_wildcard, b, MTU)) {
			prints("net: could not populate the ring with buffer");
		}
	}
	NET_LOCK_RELEASE();

	return 0;
}
コード例 #3
0
ファイル: evt.c プロジェクト: asweeney86/Composite
void cos_init(void *arg)
{
	lock_static_init(&evt_lock);
	cos_map_init_static(&evt_map);
	if (mapping_create(NULL) != 0) BUG();
	INIT_LIST(&grps, next, prev);
}
コード例 #4
0
int portmgr_bind(spdid_t spdid, u16_t port)
{
	if (!lock_initialized) {
		lock_initialized = 1;
		lock_static_init(&port_lock);
	}

	return 0;
}
コード例 #5
0
int portmgr_new(spdid_t spdid)
{
	if (!lock_initialized) {
		lock_initialized = 1;
		lock_static_init(&port_lock);
	}

	return 1;
}
コード例 #6
0
ファイル: conn_mgr.c プロジェクト: RobertGiff/Composite
void
cos_init(void *arg)
{
	int c, accept_fd, ret;
	long eid;
	char *init_str = cos_init_args(), *create_str;
	int lag, nthds, prio;
	
	cvect_init_static(&evts);
	cvect_init_static(&tor_from);
	cvect_init_static(&tor_to);
	lock_static_init(&sc_lock);
		
	sscanf(init_str, "%d:%d:%d", &lag, &nthds, &prio);
	printc("lag: %d, nthds:%d, prio:%d\n", lag, nthds, prio);
	create_str = strstr(init_str, "/");
	assert(create_str);

	eid = evt_get();
	ret = c = from_tsplit(cos_spd_id(), td_root, create_str, strlen(create_str), TOR_ALL, eid);
	if (ret <= td_root) BUG();
	accept_fd = c;
	evt_add(c, eid);

	/* event loop... */
	while (1) {
		struct tor_conn tc;
		int t;
		long evt;

		memset(&tc, 0, sizeof(struct tor_conn));
		evt = evt_wait_all();
		t   = evt_torrent(evt);

		if (t > 0) {
			tc.feid = evt;
			tc.from = t;
			if (t == accept_fd) {
				tc.to = 0;
				accept_new(accept_fd);
			} else {
				tc.to = tor_get_to(t, &tc.teid);
				assert(tc.to > 0);
				from_data_new(&tc);
			}
		} else {
			t *= -1;
			tc.teid = evt;
			tc.to   = t;
			tc.from = tor_get_from(t, &tc.feid);
			assert(tc.from > 0);
			to_data_new(&tc);
		}

		cos_mpd_update();
	}
}
コード例 #7
0
ファイル: cbuf_c.c プロジェクト: songjiguo/C3
CCTOR static void
cbuf_init(void)
{
	int i;

	lock_static_init(&cbuf_lock);
	for (i = 0 ; i < CBUFP_MAX_NSZ/2 ; i++) {
		cbufp_alloc_freelists[i].next = cbufp_alloc_freelists[i].prev = &cbufp_alloc_freelists[i];
		cbufp_alloc_freelists[i].length = PAGE_SIZE << i;
		cbufp_alloc_freelists[i].addr   = NULL;
	}
}
コード例 #8
0
int cos_init(void)
{
	int i;

	lock_static_init(&l);
	torlib_init();
	for (i = 0 ; i < COS_TRANS_SERVICE_MAX ; i++) {
		channel_init(i);
	}

	return 0;
}
コード例 #9
0
ファイル: https.c プロジェクト: Neymello/Composite
static struct connection *http_new_connection(long conn_id, long evt_id)
{
	struct connection *c = malloc(sizeof(struct connection));

	if (NULL == c) return c;
	c->conn_id = conn_id;
	c->evt_id = evt_id;
	c->pending_reqs = NULL;
	c->refcnt = 1;
	lock_static_init(&c->lock);

	return c;
}
コード例 #10
0
ファイル: https.c プロジェクト: Neymello/Composite
void cos_init(void *arg)
{
	torlib_init();
	lock_static_init(&h_lock);

	if (periodic_wake_create(cos_spd_id(), HTTP_REPORT_FREQ)) BUG();
	while (1) {
		periodic_wake_wait(cos_spd_id());
		printc("HTTP conns %ld, reqs %ld\n", http_conn_cnt, http_req_cnt);
		http_conn_cnt = http_req_cnt = 0;
	}
	
	return;
}
コード例 #11
0
ファイル: netif.c プロジェクト: wittrock/Composite
static void rb_init(rb_meta_t *rbm, ring_buff_t *rb)
{
	int i;

	for (i = 0 ; i < RB_SIZE ; i++) {
		rb->packets[i].status = RB_EMPTY;
	}
	memset(rbm, 0, sizeof(rb_meta_t));
	rbm->rb_head       = 0;
	rbm->rb_tail       = RB_SIZE-1;
	rbm->rb            = rb;
//	rbm->curr_buffs    = rbm->max_buffs     = 0; 
//	rbm->tot_principal = rbm->max_principal = 0;
	lock_static_init(&rbm->l);
	INIT_LIST(&rbm->used_pages, next, prev);
	INIT_LIST(&rbm->avail_pages, next, prev);
}
コード例 #12
0
ファイル: cos_net.c プロジェクト: songjiguo/C3
static int init(void) 
{
	int cnt = 0;
#ifdef LWIP_STATS
	int stats_cnt = 0;
#endif

	lock_static_init(&net_lock);
	/* printc("netlock id %d\n", net_lock.lock_id); */
	NET_LOCK_TAKE();

	torlib_init();
	net_conn_init();
	cos_net_create_netif_thd();
	init_lwip();

	NET_LOCK_RELEASE();
	/* Start the tcp timer */
	while (1) {
		/* Sleep for a quarter of seconds as prescribed by lwip */
		NET_LOCK_TAKE();

		if (++cnt == 4) {
#ifdef TEST_TIMING
			timing_output();
#endif
		}
#ifdef LWIP_STATS
		if (++stats_cnt == 20) {
			stats_cnt = 0;
			stats_display();
		}
#endif
		tcp_tmr();
		NET_LOCK_RELEASE();
		timed_event_block(cos_spd_id(), 25); /* expressed in ticks currently */
		/* printc("use timer to tcp debug thread here...\n"); */
		cos_mpd_update();
	}

	prints("net: Error -- returning from init!!!");
	BUG();
	return 0;
}
コード例 #13
0
ファイル: pid.c プロジェクト: songjiguo/Monitor_ML
static void init(char *init_str)
{
	int nthds;

	cvect_init_static(&evts);
	cvect_init_static(&tor_from);
	cvect_init_static(&tor_to);
	lock_static_init(&sc_lock);
		
	sscanf(init_str, "%d:%d:%d", &nthds, &__prio, &__port);
	/* printc("nthds:%d, prio:%d, port %d\n", nthds, __prio, __port); */
	create_str = strstr(init_str, "/");
	assert(create_str);

	for (; nthds > 0 ; nthds--) {
		union sched_param sp;
		int thdid;
		
		sp.c.type  = SCHEDP_PRIO;
		sp.c.value = __prio++;
		thdid = sched_create_thd(cos_spd_id(), sp.v, 0, 0);
	}
}