From de4e29288d30183ca78a5e0878431ed47fa58b8f Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Thu, 21 Aug 2014 17:49:05 -0700 Subject: Fix for crazy Windows threading bug... repeatedly adding and removing a network now doesn't leave networks in limbo. --- osnet/WindowsEthernetTapFactory.cpp | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'osnet/WindowsEthernetTapFactory.cpp') diff --git a/osnet/WindowsEthernetTapFactory.cpp b/osnet/WindowsEthernetTapFactory.cpp index 74703077..b2ff422a 100644 --- a/osnet/WindowsEthernetTapFactory.cpp +++ b/osnet/WindowsEthernetTapFactory.cpp @@ -75,6 +75,9 @@ EthernetTap *WindowsEthernetTapFactory::open( void WindowsEthernetTapFactory::close(EthernetTap *tap,bool destroyPersistentDevices) { + if (!tap) + return; + std::string instanceId(((WindowsEthernetTap *)tap)->instanceId()); Mutex::Lock _l(_devices_m); @@ -120,20 +123,8 @@ void WindowsEthernetTapFactory::destroyAllPersistentTapDevices(const char *pathT dataLen = sizeof(data); if (RegGetValueA(nwAdapters,subkeyName,"DeviceInstanceID",RRF_RT_ANY,&type,(PVOID)data,&dataLen) == ERROR_SUCCESS) instanceIdPath.assign(data,dataLen); - if (instanceIdPath.length() != 0) { + if (instanceIdPath.length() != 0) instanceIdPathsToRemove.insert(instanceIdPath); - /* - type = 0; - dataLen = sizeof(data); - if (RegGetValueA(nwAdapters,subkeyName,"_ZeroTierTapIdentifier",RRF_RT_ANY,&type,(PVOID)data,&dataLen) == ERROR_SUCCESS) { - if (dataLen <= 0) { - instanceIdPathsToRemove.insert(instanceIdPath); - } else { - instanceIdPathsToRemove.insert(instanceIdPath); - } - } - */ - } } } } else break; // end of list or failure -- cgit v1.2.3