From 2659427864aee89977a58440705f7069c0e6c639 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Tue, 30 Sep 2014 16:28:25 -0700 Subject: Multicaster needs to be global, not per-network, and a bunch of other stuff. --- node/Network.cpp | 57 ++++++++++++++++++++++++++------------------------------ 1 file changed, 26 insertions(+), 31 deletions(-) (limited to 'node/Network.cpp') 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::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::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::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::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::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::iterator mg(_multicastGroupsBehindMe.begin());mg!=_multicastGroupsBehindMe.end();) { + if ((now - mg->second) > (ZT_MULTICAST_LIKE_EXPIRE * 2)) + _multicastGroupsBehindMe.erase(mg++); + else ++mg; } } -- cgit v1.2.3