diff options
| author | Adam Ierymenko <adam.ierymenko@zerotier.com> | 2015-05-19 18:13:20 -0700 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@zerotier.com> | 2015-05-19 18:13:20 -0700 |
| commit | c7eb5f0c81d32f26d0cca47f80d9d9d5e1307aca (patch) | |
| tree | 34911b7ad734d3aabd1fe7c016e97b8c2ee88a56 /osdep | |
| parent | 68cb7ad4cdeac23988bc63cd65f91d8b540ff47d (diff) | |
| download | infinitytier-c7eb5f0c81d32f26d0cca47f80d9d9d5e1307aca.tar.gz infinitytier-c7eb5f0c81d32f26d0cca47f80d9d9d5e1307aca.zip | |
Windows build warning removal, be more defensive in Windows tap driver code, and clean up service start/stop in installer.
Diffstat (limited to 'osdep')
| -rw-r--r-- | osdep/WindowsEthernetTap.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/osdep/WindowsEthernetTap.cpp b/osdep/WindowsEthernetTap.cpp index 4a5d32a4..1cea0d96 100644 --- a/osdep/WindowsEthernetTap.cpp +++ b/osdep/WindowsEthernetTap.cpp @@ -594,7 +594,10 @@ 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... while (_run) { + 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); @@ -698,7 +701,8 @@ void WindowsEthernetTap::threadMain() ReadFile(_tap,tapReadBuf,sizeof(tapReadBuf),NULL,&tapOvlRead); bool writeInProgress = false; while (_run) { - if (prevTapResetStatus != _systemTapResetStatus) { + if ((prevTapResetStatus != _systemTapResetStatus)||(throwOneAway)) { + throwOneAway = false; prevTapResetStatus = _systemTapResetStatus; break; // this will cause us to close and reopen the tap } |
