summaryrefslogtreecommitdiff
path: root/osdep
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@zerotier.com>2015-05-20 14:21:14 -0700
committerAdam Ierymenko <adam.ierymenko@zerotier.com>2015-05-20 14:21:14 -0700
commit6fc090eb006e69ace769b0a5338e13128f2ddbd9 (patch)
tree34bd05fa87781019673aec79eac5278631fede54 /osdep
parent0caac25d28a3c08b91020ed8fa893887229c017a (diff)
downloadinfinitytier-6fc090eb006e69ace769b0a5338e13128f2ddbd9.tar.gz
infinitytier-6fc090eb006e69ace769b0a5338e13128f2ddbd9.zip
Don't actually "power cycle" the interface except on startup. Doing that after we're running could lose IP configuration.
Diffstat (limited to 'osdep')
-rw-r--r--osdep/WindowsEthernetTap.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/osdep/WindowsEthernetTap.cpp b/osdep/WindowsEthernetTap.cpp
index 77e7dc9c..b373d9e2 100644
--- a/osdep/WindowsEthernetTap.cpp
+++ b/osdep/WindowsEthernetTap.cpp
@@ -589,16 +589,20 @@ void WindowsEthernetTap::threadMain()
Utils::snprintf(tapPath,sizeof(tapPath),"\\\\.\\Global\\%s.tap",_netCfgInstanceId.c_str());
int prevTapResetStatus = _systemTapResetStatus;
- bool throwOneAway = true; // "Power cycle" the network port once on startup, because Windows...
+ bool throwOneAway = true; // Restart once on startup, because Windows.
+ bool powerCycle = true; // If true, "power cycle" the device, because Windows.
while (_run) {
- _disableTapDevice();
- Sleep(500);
- _enableTapDevice();
- Sleep(500);
+ if (powerCycle) {
+ _disableTapDevice();
+ Sleep(500);
+ _enableTapDevice();
+ Sleep(500);
+ }
_tap = CreateFileA(tapPath,GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_SYSTEM|FILE_FLAG_OVERLAPPED,NULL);
if (_tap == INVALID_HANDLE_VALUE) {
fprintf(stderr,"Error opening %s -- retrying.\r\n",tapPath);
+ powerCycle = true;
continue;
}
@@ -700,6 +704,7 @@ void WindowsEthernetTap::threadMain()
bool writeInProgress = false;
while (_run) {
if ((prevTapResetStatus != _systemTapResetStatus)||(throwOneAway)) {
+ powerCycle = throwOneAway;
throwOneAway = false;
prevTapResetStatus = _systemTapResetStatus;
break; // this will cause us to close and reopen the tap