diff options
author | Grant Limberg <glimberg@gmail.com> | 2015-05-21 19:14:49 -0700 |
---|---|---|
committer | Grant Limberg <glimberg@gmail.com> | 2015-05-21 19:14:49 -0700 |
commit | c430d88bd40d178685ac0a2e648d8c4ea675996c (patch) | |
tree | f69f497428fa34c6389173d39c889563dea9506c /osdep/WindowsEthernetTap.cpp | |
parent | 9a00366b18bc2bdb3ddf4345edcc7a459eb5ed60 (diff) | |
parent | d9006712f6ffc975d97097caf2d2b4264405b32c (diff) | |
download | infinitytier-c430d88bd40d178685ac0a2e648d8c4ea675996c.tar.gz infinitytier-c430d88bd40d178685ac0a2e648d8c4ea675996c.zip |
Merge branch 'adamierymenko-dev' into android-jni
Conflicts:
.gitignore
Diffstat (limited to 'osdep/WindowsEthernetTap.cpp')
-rw-r--r-- | osdep/WindowsEthernetTap.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/osdep/WindowsEthernetTap.cpp b/osdep/WindowsEthernetTap.cpp index 4a5d32a4..b373d9e2 100644 --- a/osdep/WindowsEthernetTap.cpp +++ b/osdep/WindowsEthernetTap.cpp @@ -578,11 +578,6 @@ void WindowsEthernetTap::threadMain() HANDLE wait4[3]; char *tapReadBuf = (char *)0; - if (!_enableTapDevice()) { - _enabled = false; - return; // only happens if devcon is missing or totally fails - } - /* No idea why I did this. I did it a long time ago and there was only a * a snarky comment. But I'd never do crap like this without a reason, so * I am leaving it alone with a more descriptive snarky comment. */ @@ -594,10 +589,20 @@ void WindowsEthernetTap::threadMain() Utils::snprintf(tapPath,sizeof(tapPath),"\\\\.\\Global\\%s.tap",_netCfgInstanceId.c_str()); int prevTapResetStatus = _systemTapResetStatus; + bool throwOneAway = true; // Restart once on startup, because Windows. + bool powerCycle = true; // If true, "power cycle" the device, because Windows. while (_run) { + if (powerCycle) { + _disableTapDevice(); + Sleep(500); + _enableTapDevice(); + 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); + powerCycle = true; continue; } @@ -698,7 +703,9 @@ void WindowsEthernetTap::threadMain() ReadFile(_tap,tapReadBuf,sizeof(tapReadBuf),NULL,&tapOvlRead); bool writeInProgress = false; while (_run) { - if (prevTapResetStatus != _systemTapResetStatus) { + if ((prevTapResetStatus != _systemTapResetStatus)||(throwOneAway)) { + powerCycle = throwOneAway; + throwOneAway = false; prevTapResetStatus = _systemTapResetStatus; break; // this will cause us to close and reopen the tap } |