mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 12:33:44 +02:00
Tweaks to WindowsEthernetTap to attempt to address GitHub issue #308 and/or GitHub issue #277 -- we can't reproduce yet but I found one area where a spin was possible under certain failure conditions. Maybe.
This commit is contained in:
parent
0aae86be2e
commit
d3cb063d13
1 changed files with 12 additions and 10 deletions
|
@ -68,7 +68,6 @@ typedef BOOL (WINAPI *SetupDiSetClassInstallParamsA_t)(_In_ HDEVINFO DeviceInfoS
|
||||||
typedef CONFIGRET (WINAPI *CM_Get_Device_ID_ExA_t)(_In_ DEVINST dnDevInst,_Out_writes_(BufferLen) PSTR Buffer,_In_ ULONG BufferLen,_In_ ULONG ulFlags,_In_opt_ HMACHINE hMachine);
|
typedef CONFIGRET (WINAPI *CM_Get_Device_ID_ExA_t)(_In_ DEVINST dnDevInst,_Out_writes_(BufferLen) PSTR Buffer,_In_ ULONG BufferLen,_In_ ULONG ulFlags,_In_opt_ HMACHINE hMachine);
|
||||||
typedef BOOL (WINAPI *SetupDiGetDeviceInstanceIdA_t)(_In_ HDEVINFO DeviceInfoSet,_In_ PSP_DEVINFO_DATA DeviceInfoData,_Out_writes_opt_(DeviceInstanceIdSize) PSTR DeviceInstanceId,_In_ DWORD DeviceInstanceIdSize,_Out_opt_ PDWORD RequiredSize);
|
typedef BOOL (WINAPI *SetupDiGetDeviceInstanceIdA_t)(_In_ HDEVINFO DeviceInfoSet,_In_ PSP_DEVINFO_DATA DeviceInfoData,_Out_writes_opt_(DeviceInstanceIdSize) PSTR DeviceInstanceId,_In_ DWORD DeviceInstanceIdSize,_Out_opt_ PDWORD RequiredSize);
|
||||||
|
|
||||||
|
|
||||||
namespace ZeroTier {
|
namespace ZeroTier {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -477,7 +476,7 @@ WindowsEthernetTap::WindowsEthernetTap(
|
||||||
std::string mySubkeyName;
|
std::string mySubkeyName;
|
||||||
|
|
||||||
if (mtu > 2800)
|
if (mtu > 2800)
|
||||||
throw std::runtime_error("MTU too large for Windows tap");
|
throw std::runtime_error("MTU too large.");
|
||||||
|
|
||||||
// We "tag" registry entries with the network ID to identify persistent devices
|
// We "tag" registry entries with the network ID to identify persistent devices
|
||||||
Utils::snprintf(tag,sizeof(tag),"%.16llx",(unsigned long long)nwid);
|
Utils::snprintf(tag,sizeof(tag),"%.16llx",(unsigned long long)nwid);
|
||||||
|
@ -869,18 +868,19 @@ void WindowsEthernetTap::threadMain()
|
||||||
try {
|
try {
|
||||||
while (_run) {
|
while (_run) {
|
||||||
// Because Windows
|
// Because Windows
|
||||||
|
Sleep(250);
|
||||||
setPersistentTapDeviceState(_deviceInstanceId.c_str(),false);
|
setPersistentTapDeviceState(_deviceInstanceId.c_str(),false);
|
||||||
Sleep(500);
|
Sleep(250);
|
||||||
setPersistentTapDeviceState(_deviceInstanceId.c_str(),true);
|
setPersistentTapDeviceState(_deviceInstanceId.c_str(),true);
|
||||||
Sleep(500);
|
Sleep(250);
|
||||||
setPersistentTapDeviceState(_deviceInstanceId.c_str(),false);
|
setPersistentTapDeviceState(_deviceInstanceId.c_str(),false);
|
||||||
Sleep(500);
|
Sleep(250);
|
||||||
setPersistentTapDeviceState(_deviceInstanceId.c_str(),true);
|
setPersistentTapDeviceState(_deviceInstanceId.c_str(),true);
|
||||||
Sleep(500);
|
Sleep(250);
|
||||||
|
|
||||||
_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) {
|
||||||
Sleep(1000);
|
Sleep(250);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -948,7 +948,7 @@ void WindowsEthernetTap::threadMain()
|
||||||
ipnr.ReachabilityTime.LastUnreachable = 1;
|
ipnr.ReachabilityTime.LastUnreachable = 1;
|
||||||
DWORD result = CreateIpNetEntry2(&ipnr);
|
DWORD result = CreateIpNetEntry2(&ipnr);
|
||||||
if (result != NO_ERROR)
|
if (result != NO_ERROR)
|
||||||
Sleep(500);
|
Sleep(250);
|
||||||
else break;
|
else break;
|
||||||
}
|
}
|
||||||
for(int i=0;i<8;++i) {
|
for(int i=0;i<8;++i) {
|
||||||
|
@ -963,7 +963,7 @@ void WindowsEthernetTap::threadMain()
|
||||||
nr.Protocol = MIB_IPPROTO_NETMGMT;
|
nr.Protocol = MIB_IPPROTO_NETMGMT;
|
||||||
DWORD result = CreateIpForwardEntry2(&nr);
|
DWORD result = CreateIpForwardEntry2(&nr);
|
||||||
if (result != NO_ERROR)
|
if (result != NO_ERROR)
|
||||||
Sleep(500);
|
Sleep(250);
|
||||||
else break;
|
else break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1021,8 +1021,10 @@ void WindowsEthernetTap::threadMain()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((waitResult == WAIT_TIMEOUT)||(waitResult == WAIT_FAILED))
|
if ((waitResult == WAIT_TIMEOUT)||(waitResult == WAIT_FAILED)) {
|
||||||
|
Sleep(250); // guard against spinning under some conditions
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (HasOverlappedIoCompleted(&tapOvlRead)) {
|
if (HasOverlappedIoCompleted(&tapOvlRead)) {
|
||||||
DWORD bytesRead = 0;
|
DWORD bytesRead = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue