mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-01 23:10:52 +00:00
Make multiple attempts to open the tap device on Windows.
This commit is contained in:
parent
e3239d23f4
commit
881ff08269
@ -1287,6 +1287,7 @@ EthernetTap::EthernetTap(
|
|||||||
CloseHandle(processInfo.hProcess);
|
CloseHandle(processInfo.hProcess);
|
||||||
CloseHandle(processInfo.hThread);
|
CloseHandle(processInfo.hThread);
|
||||||
}
|
}
|
||||||
|
Sleep(250);
|
||||||
{
|
{
|
||||||
STARTUPINFOA startupInfo;
|
STARTUPINFOA startupInfo;
|
||||||
startupInfo.cb = sizeof(startupInfo);
|
startupInfo.cb = sizeof(startupInfo);
|
||||||
@ -1309,14 +1310,22 @@ EthernetTap::EthernetTap(
|
|||||||
}
|
}
|
||||||
if (devconLog != INVALID_HANDLE_VALUE)
|
if (devconLog != INVALID_HANDLE_VALUE)
|
||||||
CloseHandle(devconLog);
|
CloseHandle(devconLog);
|
||||||
|
Sleep(250);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open the tap, which is in this weird Windows analog of /dev
|
// Open the tap, which is in this weird Windows analog of /dev
|
||||||
char tapPath[4096];
|
char tapPath[4096];
|
||||||
Utils::snprintf(tapPath,sizeof(tapPath),"\\\\.\\Global\\%s.tap",_myDeviceInstanceId.c_str());
|
Utils::snprintf(tapPath,sizeof(tapPath),"\\\\.\\Global\\%s.tap",_myDeviceInstanceId.c_str());
|
||||||
_tap = CreateFileA(tapPath,GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_SYSTEM|FILE_FLAG_OVERLAPPED,NULL);
|
for(int openTrials=0;;) {
|
||||||
if (_tap == INVALID_HANDLE_VALUE)
|
// Try multiple times, since there seem to be reports from the field
|
||||||
throw std::runtime_error(std::string("unable to open tap device ")+tapPath);
|
// of driver init timing issues. Blech.
|
||||||
|
_tap = CreateFileA(tapPath,GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_SYSTEM|FILE_FLAG_OVERLAPPED,NULL);
|
||||||
|
if (_tap == INVALID_HANDLE_VALUE) {
|
||||||
|
if (++openTrials >= 3)
|
||||||
|
throw std::runtime_error(std::string("unable to open tap device ")+tapPath);
|
||||||
|
else Sleep(500);
|
||||||
|
} else break;
|
||||||
|
}
|
||||||
|
|
||||||
// Set media status to enabled
|
// Set media status to enabled
|
||||||
uint32_t tmpi = 1;
|
uint32_t tmpi = 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user