mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-01-18 10:46:33 +00:00
Clean controller circuit test memory.
This commit is contained in:
parent
43fff1a87e
commit
9b59bcd995
@ -1059,7 +1059,27 @@ void SqliteNetworkController::threadMain()
|
||||
throw()
|
||||
{
|
||||
uint64_t lastBackupTime = OSUtils::now();
|
||||
uint64_t lastCleanupTime = OSUtils::now();
|
||||
|
||||
while (_backupThreadRun) {
|
||||
if ((OSUtils::now() - lastCleanupTime) >= 5000) {
|
||||
const uint64_t now = OSUtils::now();
|
||||
lastCleanupTime = now;
|
||||
|
||||
Mutex::Lock _l(_lock);
|
||||
|
||||
// Clean out really old circuit tests to prevent memory build-up
|
||||
for(std::map< uint64_t,_CircuitTestEntry >::iterator ct(_circuitTests.begin());ct!=_circuitTests.end();) {
|
||||
if (!ct->second.test) {
|
||||
_circuitTests.erase(ct++);
|
||||
} else if ((now - ct->second.test->timestamp) >= ZT_SQLITENETWORKCONTROLLER_CIRCUIT_TEST_TIMEOUT) {
|
||||
_node->circuitTestEnd(ct->second.test);
|
||||
::free((void *)ct->second.test);
|
||||
_circuitTests.erase(ct++);
|
||||
} else ++ct;
|
||||
}
|
||||
}
|
||||
|
||||
if ((OSUtils::now() - lastBackupTime) >= ZT_NETCONF_BACKUP_PERIOD) {
|
||||
lastBackupTime = OSUtils::now();
|
||||
|
||||
@ -1104,6 +1124,7 @@ void SqliteNetworkController::threadMain()
|
||||
OSUtils::rm(backupPath2);
|
||||
::rename(backupPath,backupPath2);
|
||||
}
|
||||
|
||||
Thread::sleep(250);
|
||||
}
|
||||
}
|
||||
@ -1319,10 +1340,6 @@ unsigned int SqliteNetworkController::_doCPGet(
|
||||
responseBody.push_back(']');
|
||||
responseContentType = "application/json";
|
||||
|
||||
_node->circuitTestEnd(cte->second.test);
|
||||
::free((void *)cte->second.test);
|
||||
_circuitTests.erase(cte);
|
||||
|
||||
return 200;
|
||||
|
||||
} // else 404
|
||||
|
@ -44,8 +44,8 @@
|
||||
// Number of in-memory last log entries to maintain per user
|
||||
#define ZT_SQLITENETWORKCONTROLLER_IN_MEMORY_LOG_SIZE 32
|
||||
|
||||
// How long do circuit tests "live"? This is just to prevent buildup in memory.
|
||||
#define ZT_SQLITENETWORKCONTROLLER_CIRCUIT_TEST_TIMEOUT 300000
|
||||
// How long do circuit tests last before they're forgotten?
|
||||
#define ZT_SQLITENETWORKCONTROLLER_CIRCUIT_TEST_TIMEOUT 60000
|
||||
|
||||
namespace ZeroTier {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user