Merge branch 'dev' of github.com:/zerotier/ZeroTierOne into dev

This commit is contained in:
Adam Ierymenko 2022-11-04 11:15:13 -04:00
commit af7ccff846
2 changed files with 30 additions and 26 deletions

View file

@ -1374,9 +1374,7 @@ void Bond::processBalanceTasks(int64_t now)
Mutex::Lock _l(_flows_m);
std::map<int16_t, SharedPtr<Flow> >::iterator flow_it = _flows.begin();
while (flow_it != _flows.end()) {
if (! _paths[flow_it->second->assignedPath].p) {
continue;
}
if (_paths[flow_it->second->assignedPath].p) {
int originalPathIdx = flow_it->second->assignedPath;
if (! _paths[originalPathIdx].eligible) {
log("moving all flows from dead link %s", pathToStr(_paths[originalPathIdx].p).c_str());
@ -1384,6 +1382,7 @@ void Bond::processBalanceTasks(int64_t now)
_paths[originalPathIdx].assignedFlowCount--;
}
}
}
++flow_it;
}
}
@ -1394,9 +1393,7 @@ void Bond::processBalanceTasks(int64_t now)
Mutex::Lock _l(_flows_m);
std::map<int16_t, SharedPtr<Flow> >::iterator flow_it = _flows.begin();
while (flow_it != _flows.end()) {
if (! _paths[flow_it->second->assignedPath].p) {
continue;
}
if (_paths[flow_it->second->assignedPath].p) {
int originalPathIdx = flow_it->second->assignedPath;
if (_paths[originalPathIdx].shouldAvoid) {
if (assignFlowToBondedPath(flow_it->second, now, true)) {
@ -1404,6 +1401,7 @@ void Bond::processBalanceTasks(int64_t now)
return; // Only move one flow at a time
}
}
}
++flow_it;
}
}

View file

@ -50,20 +50,26 @@ std::string InstallService(PSTR pszServiceName,
PSTR pszPassword)
{
std::string ret;
char szPathTmp[MAX_PATH],szPath[MAX_PATH];
std::string path(0x7FFF, '\0');
SC_HANDLE schSCManager = NULL;
SC_HANDLE schService = NULL;
SERVICE_DESCRIPTION sd;
LPTSTR szDesc = TEXT("ZeroTier network virtualization service.");
if (GetModuleFileName(NULL, szPathTmp, ARRAYSIZE(szPath)) == 0)
DWORD dwCharacters = GetModuleFileName(NULL, path.data(), path.size());
if (dwCharacters == 0)
{
ret = "GetModuleFileName failed, unable to get path to self";
goto Cleanup;
}
// Trim excess nulls which the returned size does not include
path.resize(dwCharacters);
// Quote path in case it contains spaces
_snprintf_s(szPath,sizeof(szPath),"\"%s\"",szPathTmp);
path = '"' + path + '"';
// Open the local default service control manager database
schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT |
@ -83,7 +89,7 @@ std::string InstallService(PSTR pszServiceName,
SERVICE_WIN32_OWN_PROCESS, // Service type
dwStartType, // Service start type
SERVICE_ERROR_NORMAL, // Error control type
szPath, // Service's binary
path.c_str(), // Service's binary
NULL, // No load ordering group
NULL, // No tag identifier
pszDependencies, // Dependencies