summaryrefslogtreecommitdiff
path: root/osdep
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@zerotier.com>2015-05-19 18:13:20 -0700
committerAdam Ierymenko <adam.ierymenko@zerotier.com>2015-05-19 18:13:20 -0700
commitc7eb5f0c81d32f26d0cca47f80d9d9d5e1307aca (patch)
tree34911b7ad734d3aabd1fe7c016e97b8c2ee88a56 /osdep
parent68cb7ad4cdeac23988bc63cd65f91d8b540ff47d (diff)
downloadinfinitytier-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.cpp6
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
}