void torflow_ready(TorFlow* tf) { g_assert(tf); /* collect the events that are ready */ struct epoll_event epevs[100]; gint nfds = epoll_wait(tf->internal->epolld, epevs, 100, 0); if(nfds == -1) { tf->_base.slogf(SHADOW_LOG_LEVEL_CRITICAL, tf->_base.id, "error in epoll_wait"); } else { /* activate correct component for every socket thats ready */ for(gint i = 0; i < nfds; i++) { gint d = epevs[i].data.fd; uint32_t e = epevs[i].events; if(d == torflowbase_getControlSD((TorFlowBase*)tf)) { torflowbase_activate((TorFlowBase*)tf, d, e); } else { /* check if we have a socks connection */ TorFlowDownload* tfd = g_hash_table_lookup(tf->internal->downloads, GINT_TO_POINTER(d)); if(tfd && d == tfd->socksd) { _torflow_activateSocksDownload(tf, tfd, e); } } } } }
static void _torflowmanager_activateBase(TorFlowManager* tfm) { /* collect the events that are ready */ struct epoll_event epevs[100]; gint nfds = epoll_wait(tfm->baseED, epevs, 100, 0); if(nfds == -1) { tfm->slogf(SHADOW_LOG_LEVEL_CRITICAL, tfm->_base.id, "error in epoll_wait"); } else { /* activate correct component for every socket thats ready */ for(gint i = 0; i < nfds; i++) { gint d = epevs[i].data.fd; uint32_t e = epevs[i].events; if(d == torflowbase_getControlSD(&tfm->_base)) { torflowbase_activate(&tfm->_base, d, e); } else { tfm->slogf(SHADOW_LOG_LEVEL_WARNING, tfm->_base.id, "got readiness on unknown descriptor: %i", d); } } } }