Added options for enabling and disabling network caching. Also modified tap polling interval

This commit is contained in:
Joseph Henry
2019-02-07 10:53:50 -08:00
parent 4de1068b57
commit 52a7e9229e
3 changed files with 95 additions and 45 deletions

View File

@@ -144,11 +144,11 @@ bool VirtualTap::addIp(const InetAddress &ip)
{
char ipbuf[INET6_ADDRSTRLEN];
Mutex::Lock _l(_ips_m);
lwip_init_interface((void*)this, this->_mac, ip);
if (std::find(_ips.begin(),_ips.end(),ip) == _ips.end()) {
_ips.push_back(ip);
std::sort(_ips.begin(),_ips.end());
}
lwip_init_interface((void*)this, this->_mac, ip);
return true;
}
@@ -256,18 +256,13 @@ void VirtualTap::threadMain()
if (FD_ISSET(_shutdownSignalPipe[0],&readfds)) {
break;
}
#ifdef _MSC_VER
Sleep(ZTS_PHY_POLL_INTERVAL);
_phy.poll(0);
#if defined(_WIN32)
Sleep(ZTS_TAP_THREAD_POLLING_INTERVAL);
#else
_phy.poll(ZTS_PHY_POLL_INTERVAL);
struct timespec sleepValue = {0};
sleepValue.tv_nsec = ZTS_TAP_THREAD_POLLING_INTERVAL * 500000;
nanosleep(&sleepValue, NULL);
#endif
uint64_t current_ts = OSUtils::now();
if (current_ts > last_housekeeping_ts + ZTS_HOUSEKEEPING_INTERVAL) {
Housekeeping();
last_housekeeping_ts = OSUtils::now();
}
}
}