summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrant Limberg <grant.limberg@zerotier.com>2017-01-09 12:41:45 -0800
committerGrant Limberg <grant.limberg@zerotier.com>2017-01-09 12:41:45 -0800
commitdbd577c6b0a6d984452d04415733c275ba6577a4 (patch)
treee832f0aa37decbb8580ad5e284dfe88a06ae795e
parent7ebb207005620ce753bed57e25afddff1bf7e80e (diff)
parent0f6c53589eb9f4faf0b2025f9e1e19c0d30b7ebb (diff)
downloadinfinitytier-dbd577c6b0a6d984452d04415733c275ba6577a4.tar.gz
infinitytier-dbd577c6b0a6d984452d04415733c275ba6577a4.zip
Merge branch 'winroute' into dev
-rw-r--r--osdep/WindowsEthernetTap.cpp6
-rw-r--r--osdep/WindowsEthernetTap.hpp2
-rw-r--r--service/OneService.cpp10
3 files changed, 17 insertions, 1 deletions
diff --git a/osdep/WindowsEthernetTap.cpp b/osdep/WindowsEthernetTap.cpp
index a9ff31d3..8ee088bb 100644
--- a/osdep/WindowsEthernetTap.cpp
+++ b/osdep/WindowsEthernetTap.cpp
@@ -640,7 +640,7 @@ WindowsEthernetTap::WindowsEthernetTap(
if (ConvertInterfaceGuidToLuid(&_deviceGuid,&_deviceLuid) != NO_ERROR)
throw std::runtime_error("unable to convert device interface GUID to LUID");
- _initialized = true;
+ //_initialized = true;
if (friendlyName)
setFriendlyName(friendlyName);
@@ -1007,6 +1007,10 @@ void WindowsEthernetTap::threadMain()
ReadFile(_tap,tapReadBuf,sizeof(tapReadBuf),NULL,&tapOvlRead);
bool writeInProgress = false;
ULONGLONG timeOfLastBorkCheck = GetTickCount64();
+
+
+ _initialized = true;
+
while (_run) {
DWORD waitResult = WaitForMultipleObjectsEx(writeInProgress ? 3 : 2,wait4,FALSE,2500,TRUE);
if (!_run) break; // will also break outer while(_run)
diff --git a/osdep/WindowsEthernetTap.hpp b/osdep/WindowsEthernetTap.hpp
index 0bbb17d8..53bba3e9 100644
--- a/osdep/WindowsEthernetTap.hpp
+++ b/osdep/WindowsEthernetTap.hpp
@@ -110,6 +110,8 @@ public:
void threadMain()
throw();
+ bool isInitialized() const { return _initialized; };
+
private:
NET_IFINDEX _getDeviceIndex(); // throws on failure
std::vector<std::string> _getRegistryIPv4Value(const char *regKey);
diff --git a/service/OneService.cpp b/service/OneService.cpp
index 3a7edacb..96b3a960 100644
--- a/service/OneService.cpp
+++ b/service/OneService.cpp
@@ -1666,6 +1666,16 @@ public:
case ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE:
memcpy(&(n.config),nwc,sizeof(ZT_VirtualNetworkConfig));
if (n.tap) { // sanity check
+#ifdef __WINDOWS__
+ // wait for up to 5 seconds for the WindowsEthernetTap to actually be initialized
+ //
+ // without WindowsEthernetTap::isInitialized() returning true, the won't actually
+ // be online yet and setting managed routes on it will fail.
+ const int MAX_SLEEP_COUNT = 500;
+ for (int i = 0; !n.tap->isInitialized() && i < MAX_SLEEP_COUNT; i++) {
+ Sleep(10);
+ }
+#endif
syncManagedStuff(n,true,true);
} else {
_nets.erase(nwid);