void event_wait(void) { struct cos_array *data; int alloc_sz; char mem[512]; data = (struct cos_array *)mem; data->sz = 4096 - sizeof(int); printc("waiting...\n"); netif_event_create(cos_spd_id()); while (1) { if (netif_event_wait(cos_spd_id(), data)) BUG();; } return; /* assert(event_thd > 0); */ /* if (ip_netif_create(cos_spd_id())) BUG(); */ /* printc("network uc %d starting...\n", cos_get_thd_id()); */ /* alloc_sz = sizeof(struct cos_array) + MTU; */ /* data = cos_argreg_alloc(alloc_sz); */ /* if (NULL == data) BUG(); */ /* while (1) { */ /* data->sz = alloc_sz; */ /* ip_wait(cos_spd_id(), data); */ /* cos_net_interrupt(data->mem, data->sz); */ /* } */ /* cos_argreg_free(data); */ /* return 0; */ }
int tread(spdid_t spdid, td_t td, int cbid, int sz) { struct torrent *t; char *buf; int ret = -1; if (tor_isnull(td)) return -EINVAL; t = tor_lookup(td); if (!t) ERR_THROW(-EINVAL, done); if (!(t->flags & TOR_WRITE)) ERR_THROW(-EACCES, done); buf = cbuf2buf(cbid, sz); if (!buf) ERR_THROW(-EINVAL, done); ret = netif_event_wait(spdid, buf, sz); /* // debug ? */ /* if (debug_first == 1) { */ /* ret = netif_event_xmit(spdid, debug_buf, debug_amnt); */ /* } */ done: return ret; }