diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2014-09-30 16:28:25 -0700 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2014-09-30 16:28:25 -0700 |
| commit | 2659427864aee89977a58440705f7069c0e6c639 (patch) | |
| tree | 21cd30ae78ed7b1df414f877d55a9243cfa342e8 /node/Network.cpp | |
| parent | 8607aa7c3c0a24c3161b605e5195bfd5a7ad1258 (diff) | |
| download | infinitytier-2659427864aee89977a58440705f7069c0e6c639.tar.gz infinitytier-2659427864aee89977a58440705f7069c0e6c639.zip | |
Multicaster needs to be global, not per-network, and a bunch of other stuff.
Diffstat (limited to 'node/Network.cpp')
| -rw-r--r-- | node/Network.cpp | 57 |
1 files changed, 26 insertions, 31 deletions
diff --git a/node/Network.cpp b/node/Network.cpp index ac3e9073..577a736e 100644 --- a/node/Network.cpp +++ b/node/Network.cpp @@ -282,43 +282,38 @@ bool Network::isAllowed(const Address &peer) const void Network::clean() { uint64_t now = Utils::now(); - { - Mutex::Lock _l(_lock); - - if (_destroyed) - return; + Mutex::Lock _l(_lock); - if ((_config)&&(_config->isPublic())) { - // Open (public) networks do not track certs or cert pushes at all. - _membershipCertificates.clear(); - _lastPushedMembershipCertificate.clear(); - } else if (_config) { - // Clean certificates that are no longer valid from the cache. - for(std::map<Address,CertificateOfMembership>::iterator c=(_membershipCertificates.begin());c!=_membershipCertificates.end();) { - if (_config->com().agreesWith(c->second)) - ++c; - else _membershipCertificates.erase(c++); - } + if (_destroyed) + return; - // Clean entries from the last pushed tracking map if they're so old as - // to be no longer relevant. - uint64_t forgetIfBefore = now - (_config->com().timestampMaxDelta() * 3ULL); - for(std::map<Address,uint64_t>::iterator lp(_lastPushedMembershipCertificate.begin());lp!=_lastPushedMembershipCertificate.end();) { - if (lp->second < forgetIfBefore) - _lastPushedMembershipCertificate.erase(lp++); - else ++lp; - } + if ((_config)&&(_config->isPublic())) { + // Open (public) networks do not track certs or cert pushes at all. + _membershipCertificates.clear(); + _lastPushedMembershipCertificate.clear(); + } else if (_config) { + // Clean certificates that are no longer valid from the cache. + for(std::map<Address,CertificateOfMembership>::iterator c=(_membershipCertificates.begin());c!=_membershipCertificates.end();) { + if (_config->com().agreesWith(c->second)) + ++c; + else _membershipCertificates.erase(c++); } - // Clean learned multicast groups if we haven't heard from them in a while - for(std::map<MulticastGroup,uint64_t>::iterator mg(_multicastGroupsBehindMe.begin());mg!=_multicastGroupsBehindMe.end();) { - if ((now - mg->second) > (ZT_MULTICAST_LIKE_EXPIRE * 2)) - _multicastGroupsBehindMe.erase(mg++); - else ++mg; + // Clean entries from the last pushed tracking map if they're so old as + // to be no longer relevant. + uint64_t forgetIfBefore = now - (_config->com().timestampMaxDelta() * 3ULL); + for(std::map<Address,uint64_t>::iterator lp(_lastPushedMembershipCertificate.begin());lp!=_lastPushedMembershipCertificate.end();) { + if (lp->second < forgetIfBefore) + _lastPushedMembershipCertificate.erase(lp++); + else ++lp; } } - { - _multicaster.clean(RR,now,(_config) ? _config->multicastLimit() : (unsigned int)ZT_MULTICAST_DEFAULT_LIMIT); + + // Clean learned multicast groups if we haven't heard from them in a while + for(std::map<MulticastGroup,uint64_t>::iterator mg(_multicastGroupsBehindMe.begin());mg!=_multicastGroupsBehindMe.end();) { + if ((now - mg->second) > (ZT_MULTICAST_LIKE_EXPIRE * 2)) + _multicastGroupsBehindMe.erase(mg++); + else ++mg; } } |
