mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-05-03 01:02:52 +00:00
Queue up managed route syncs and do them periodically to avoid dependency problems.
This commit is contained in:
parent
e8be28734b
commit
bb62279a20
@ -43,7 +43,6 @@
|
|||||||
#include "../node/Peer.hpp"
|
#include "../node/Peer.hpp"
|
||||||
|
|
||||||
#include "../osdep/Phy.hpp"
|
#include "../osdep/Phy.hpp"
|
||||||
#include "../osdep/Thread.hpp"
|
|
||||||
#include "../osdep/OSUtils.hpp"
|
#include "../osdep/OSUtils.hpp"
|
||||||
#include "../osdep/Http.hpp"
|
#include "../osdep/Http.hpp"
|
||||||
#include "../osdep/PortMapper.hpp"
|
#include "../osdep/PortMapper.hpp"
|
||||||
@ -530,6 +529,7 @@ public:
|
|||||||
ZT_VirtualNetworkConfig config; // memcpy() of raw config from core
|
ZT_VirtualNetworkConfig config; // memcpy() of raw config from core
|
||||||
std::vector<InetAddress> managedIps;
|
std::vector<InetAddress> managedIps;
|
||||||
std::map< InetAddress, SharedPtr<ManagedRoute> > managedRoutes;
|
std::map< InetAddress, SharedPtr<ManagedRoute> > managedRoutes;
|
||||||
|
std::list< InetAddress > routeSyncQueue;
|
||||||
NetworkSettings settings;
|
NetworkSettings settings;
|
||||||
};
|
};
|
||||||
std::map<uint64_t,NetworkState> _nets;
|
std::map<uint64_t,NetworkState> _nets;
|
||||||
@ -918,8 +918,23 @@ public:
|
|||||||
OSUtils::cleanDirectory((_homePath + ZT_PATH_SEPARATOR_S "peers.d").c_str(),now - 2592000000LL); // delete older than 30 days
|
OSUtils::cleanDirectory((_homePath + ZT_PATH_SEPARATOR_S "peers.d").c_str(),now - 2592000000LL); // delete older than 30 days
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned long delay = (dl > now) ? (unsigned long)(dl - now) : 100;
|
// Check to see if we have to sync any managed routes, and if so do it every 100ms to
|
||||||
clockShouldBe = now + (uint64_t)delay;
|
// avoid route dependency problems.
|
||||||
|
{
|
||||||
|
Mutex::Lock nl(_nets_m);
|
||||||
|
for(std::map<uint64_t,NetworkState>::iterator n(_nets.begin());n!=_nets.end();++n) {
|
||||||
|
if (!n->second.routeSyncQueue.empty()) {
|
||||||
|
std::map< InetAddress, SharedPtr<ManagedRoute> >::const_iterator mr(n->second.managedRoutes.find(n->second.routeSyncQueue.front()));
|
||||||
|
if (mr != n->second.managedRoutes.end())
|
||||||
|
mr->second->sync();
|
||||||
|
n->second.routeSyncQueue.pop_front();
|
||||||
|
dl = now + 100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const unsigned long delay = (dl > now) ? (unsigned long)(dl - now) : 500;
|
||||||
|
clockShouldBe = now + (int64_t)delay;
|
||||||
_phy.poll(delay);
|
_phy.poll(delay);
|
||||||
}
|
}
|
||||||
} catch (std::exception &e) {
|
} catch (std::exception &e) {
|
||||||
@ -2003,11 +2018,11 @@ public:
|
|||||||
// that do not yet have routes in the system.
|
// that do not yet have routes in the system.
|
||||||
for(std::map< InetAddress, SharedPtr<ManagedRoute> >::iterator r(n.managedRoutes.begin());r!=n.managedRoutes.end();++r) {
|
for(std::map< InetAddress, SharedPtr<ManagedRoute> >::iterator r(n.managedRoutes.begin());r!=n.managedRoutes.end();++r) {
|
||||||
if (!r->second->via())
|
if (!r->second->via())
|
||||||
r->second->sync();
|
n.routeSyncQueue.push_back(r->first);
|
||||||
}
|
}
|
||||||
for(std::map< InetAddress, SharedPtr<ManagedRoute> >::iterator r(n.managedRoutes.begin());r!=n.managedRoutes.end();++r) {
|
for(std::map< InetAddress, SharedPtr<ManagedRoute> >::iterator r(n.managedRoutes.begin());r!=n.managedRoutes.end();++r) {
|
||||||
if (r->second->via())
|
if (r->second->via())
|
||||||
r->second->sync();
|
n.routeSyncQueue.push_back(r->first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user