summaryrefslogtreecommitdiff
path: root/service/One.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2015-04-15 13:09:20 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2015-04-15 13:09:20 -0700
commit1c9ca73065975b137deb6770b4624886942c2605 (patch)
tree68877dfbf02796160ae53f3d2e591564afb9a252 /service/One.cpp
parent508519b62a9a7eae47c1000d56c85c645dae0b55 (diff)
downloadinfinitytier-1c9ca73065975b137deb6770b4624886942c2605.tar.gz
infinitytier-1c9ca73065975b137deb6770b4624886942c2605.zip
Fix some deadlock issues, move awareness of broadcast subscription into core, other bug fixes.
Diffstat (limited to 'service/One.cpp')
-rw-r--r--service/One.cpp45
1 files changed, 17 insertions, 28 deletions
diff --git a/service/One.cpp b/service/One.cpp
index bc42bba8..287f7813 100644
--- a/service/One.cpp
+++ b/service/One.cpp
@@ -228,19 +228,22 @@ public:
uint64_t dl = _nextBackgroundTaskDeadline;
uint64_t now = OSUtils::now();
-
if (dl <= now) {
- if ((now - lastTapMulticastGroupCheck) >= ZT_TAP_CHECK_MULTICAST_INTERVAL) {
- lastTapMulticastGroupCheck = now;
- Mutex::Lock _l(_taps_m);
- for(std::map< uint64_t,EthernetTap *>::const_iterator t(_taps.begin());t!=_taps.end();++t)
- _updateMulticastGroups(t->first,t->second);
- }
-
_node->processBackgroundTasks(now,&_nextBackgroundTaskDeadline);
-
dl = _nextBackgroundTaskDeadline;
- now = OSUtils::now();
+ }
+
+ if ((now - lastTapMulticastGroupCheck) >= ZT_TAP_CHECK_MULTICAST_INTERVAL) {
+ lastTapMulticastGroupCheck = now;
+ Mutex::Lock _l(_taps_m);
+ for(std::map< uint64_t,EthernetTap *>::const_iterator t(_taps.begin());t!=_taps.end();++t) {
+ std::vector<MulticastGroup> added,removed;
+ t->second->scanMulticastGroups(added,removed);
+ for(std::vector<MulticastGroup>::iterator m(added.begin());m!=added.end();++m)
+ _node->multicastSubscribe(t->first,m->mac().toInt(),m->adi());
+ for(std::vector<MulticastGroup>::iterator m(removed.begin());m!=removed.end();++m)
+ _node->multicastUnsubscribe(t->first,m->mac().toInt(),m->adi());
+ }
}
const unsigned long delay = (dl > now) ? (unsigned long)(dl - now) : 100;
@@ -409,7 +412,7 @@ public:
StapFrameHandler,
(void *)this))).first;
} catch ( ... ) {
- return -999;
+ return -999; // tap init failed
}
}
// fall through...
@@ -432,11 +435,8 @@ public:
t->second->removeIp(*ip);
}
assignedIps.swap(newAssignedIps);
-
- _updateMulticastGroups(t->first,t->second);
- if (nwc->broadcastEnabled)
- _node->multicastSubscribe(nwid,0xffffffffffffULL,0);
- else _node->multicastUnsubscribe(nwid,0xffffffffffffULL,0);
+ } else {
+ return -999; // tap init failed
}
break;
case ZT1_VIRTUAL_NETWORK_CONFIG_OPERATION_DOWN:
@@ -627,17 +627,6 @@ private:
return p;
}
- void _updateMulticastGroups(uint64_t nwid,EthernetTap *tap)
- {
- // assumes _taps_m is locked
- std::vector<MulticastGroup> added,removed;
- tap->scanMulticastGroups(added,removed);
- for(std::vector<MulticastGroup>::iterator m(added.begin());m!=added.end();++m)
- _node->multicastSubscribe(nwid,m->mac().toInt(),m->adi());
- for(std::vector<MulticastGroup>::iterator m(removed.begin());m!=removed.end();++m)
- _node->multicastUnsubscribe(nwid,m->mac().toInt(),m->adi());
- }
-
const std::string _homePath;
Phy<OneImpl *> _phy;
NetworkConfigMaster *_master;
@@ -648,7 +637,7 @@ private:
PhySocket *_v4TcpListenSocket;
PhySocket *_v6TcpListenSocket;
ControlPlane *_controlPlane;
- uint64_t _nextBackgroundTaskDeadline;
+ volatile uint64_t _nextBackgroundTaskDeadline;
std::map< uint64_t,EthernetTap * > _taps;
std::map< uint64_t,std::vector<InetAddress> > _tapAssignedIps; // ZeroTier assigned IPs, not user or dhcp assigned