mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-22 22:32:22 +00:00
Don't actually "power cycle" the interface except on startup. Doing that after we're running could lose IP configuration.
This commit is contained in:
parent
0caac25d28
commit
6fc090eb00
@ -589,16 +589,20 @@ void WindowsEthernetTap::threadMain()
|
|||||||
|
|
||||||
Utils::snprintf(tapPath,sizeof(tapPath),"\\\\.\\Global\\%s.tap",_netCfgInstanceId.c_str());
|
Utils::snprintf(tapPath,sizeof(tapPath),"\\\\.\\Global\\%s.tap",_netCfgInstanceId.c_str());
|
||||||
int prevTapResetStatus = _systemTapResetStatus;
|
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) {
|
while (_run) {
|
||||||
_disableTapDevice();
|
if (powerCycle) {
|
||||||
Sleep(500);
|
_disableTapDevice();
|
||||||
_enableTapDevice();
|
Sleep(500);
|
||||||
Sleep(500);
|
_enableTapDevice();
|
||||||
|
Sleep(500);
|
||||||
|
}
|
||||||
|
|
||||||
_tap = CreateFileA(tapPath,GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_SYSTEM|FILE_FLAG_OVERLAPPED,NULL);
|
_tap = CreateFileA(tapPath,GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_SYSTEM|FILE_FLAG_OVERLAPPED,NULL);
|
||||||
if (_tap == INVALID_HANDLE_VALUE) {
|
if (_tap == INVALID_HANDLE_VALUE) {
|
||||||
fprintf(stderr,"Error opening %s -- retrying.\r\n",tapPath);
|
fprintf(stderr,"Error opening %s -- retrying.\r\n",tapPath);
|
||||||
|
powerCycle = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -700,6 +704,7 @@ void WindowsEthernetTap::threadMain()
|
|||||||
bool writeInProgress = false;
|
bool writeInProgress = false;
|
||||||
while (_run) {
|
while (_run) {
|
||||||
if ((prevTapResetStatus != _systemTapResetStatus)||(throwOneAway)) {
|
if ((prevTapResetStatus != _systemTapResetStatus)||(throwOneAway)) {
|
||||||
|
powerCycle = throwOneAway;
|
||||||
throwOneAway = false;
|
throwOneAway = false;
|
||||||
prevTapResetStatus = _systemTapResetStatus;
|
prevTapResetStatus = _systemTapResetStatus;
|
||||||
break; // this will cause us to close and reopen the tap
|
break; // this will cause us to close and reopen the tap
|
||||||
|
Loading…
Reference in New Issue
Block a user