mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 12:33:44 +02:00
Merge branch 'dev' of github.com:/zerotier/ZeroTierOne into dev
This commit is contained in:
commit
af7ccff846
2 changed files with 30 additions and 26 deletions
|
@ -1374,14 +1374,13 @@ void Bond::processBalanceTasks(int64_t now)
|
||||||
Mutex::Lock _l(_flows_m);
|
Mutex::Lock _l(_flows_m);
|
||||||
std::map<int16_t, SharedPtr<Flow> >::iterator flow_it = _flows.begin();
|
std::map<int16_t, SharedPtr<Flow> >::iterator flow_it = _flows.begin();
|
||||||
while (flow_it != _flows.end()) {
|
while (flow_it != _flows.end()) {
|
||||||
if (! _paths[flow_it->second->assignedPath].p) {
|
if (_paths[flow_it->second->assignedPath].p) {
|
||||||
continue;
|
int originalPathIdx = flow_it->second->assignedPath;
|
||||||
}
|
if (! _paths[originalPathIdx].eligible) {
|
||||||
int originalPathIdx = flow_it->second->assignedPath;
|
log("moving all flows from dead link %s", pathToStr(_paths[originalPathIdx].p).c_str());
|
||||||
if (! _paths[originalPathIdx].eligible) {
|
if (assignFlowToBondedPath(flow_it->second, now, true)) {
|
||||||
log("moving all flows from dead link %s", pathToStr(_paths[originalPathIdx].p).c_str());
|
_paths[originalPathIdx].assignedFlowCount--;
|
||||||
if (assignFlowToBondedPath(flow_it->second, now, true)) {
|
}
|
||||||
_paths[originalPathIdx].assignedFlowCount--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
++flow_it;
|
++flow_it;
|
||||||
|
@ -1394,14 +1393,13 @@ void Bond::processBalanceTasks(int64_t now)
|
||||||
Mutex::Lock _l(_flows_m);
|
Mutex::Lock _l(_flows_m);
|
||||||
std::map<int16_t, SharedPtr<Flow> >::iterator flow_it = _flows.begin();
|
std::map<int16_t, SharedPtr<Flow> >::iterator flow_it = _flows.begin();
|
||||||
while (flow_it != _flows.end()) {
|
while (flow_it != _flows.end()) {
|
||||||
if (! _paths[flow_it->second->assignedPath].p) {
|
if (_paths[flow_it->second->assignedPath].p) {
|
||||||
continue;
|
int originalPathIdx = flow_it->second->assignedPath;
|
||||||
}
|
if (_paths[originalPathIdx].shouldAvoid) {
|
||||||
int originalPathIdx = flow_it->second->assignedPath;
|
if (assignFlowToBondedPath(flow_it->second, now, true)) {
|
||||||
if (_paths[originalPathIdx].shouldAvoid) {
|
_paths[originalPathIdx].assignedFlowCount--;
|
||||||
if (assignFlowToBondedPath(flow_it->second, now, true)) {
|
return; // Only move one flow at a time
|
||||||
_paths[originalPathIdx].assignedFlowCount--;
|
}
|
||||||
return; // Only move one flow at a time
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
++flow_it;
|
++flow_it;
|
||||||
|
|
|
@ -49,28 +49,34 @@ std::string InstallService(PSTR pszServiceName,
|
||||||
PSTR pszAccount,
|
PSTR pszAccount,
|
||||||
PSTR pszPassword)
|
PSTR pszPassword)
|
||||||
{
|
{
|
||||||
std::string ret;
|
std::string ret;
|
||||||
char szPathTmp[MAX_PATH],szPath[MAX_PATH];
|
std::string path(0x7FFF, '\0');
|
||||||
|
|
||||||
SC_HANDLE schSCManager = NULL;
|
SC_HANDLE schSCManager = NULL;
|
||||||
SC_HANDLE schService = NULL;
|
SC_HANDLE schService = NULL;
|
||||||
SERVICE_DESCRIPTION sd;
|
SERVICE_DESCRIPTION sd;
|
||||||
LPTSTR szDesc = TEXT("ZeroTier network virtualization service.");
|
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";
|
ret = "GetModuleFileName failed, unable to get path to self";
|
||||||
goto Cleanup;
|
goto Cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Quote path in case it contains spaces
|
// Trim excess nulls which the returned size does not include
|
||||||
_snprintf_s(szPath,sizeof(szPath),"\"%s\"",szPathTmp);
|
path.resize(dwCharacters);
|
||||||
|
|
||||||
|
// Quote path in case it contains spaces
|
||||||
|
path = '"' + path + '"';
|
||||||
|
|
||||||
// Open the local default service control manager database
|
// Open the local default service control manager database
|
||||||
schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT |
|
schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT |
|
||||||
SC_MANAGER_CREATE_SERVICE);
|
SC_MANAGER_CREATE_SERVICE);
|
||||||
if (schSCManager == NULL)
|
if (schSCManager == NULL)
|
||||||
{
|
{
|
||||||
ret = "OpenSCManager failed";
|
ret = "OpenSCManager failed";
|
||||||
goto Cleanup;
|
goto Cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +89,7 @@ std::string InstallService(PSTR pszServiceName,
|
||||||
SERVICE_WIN32_OWN_PROCESS, // Service type
|
SERVICE_WIN32_OWN_PROCESS, // Service type
|
||||||
dwStartType, // Service start type
|
dwStartType, // Service start type
|
||||||
SERVICE_ERROR_NORMAL, // Error control type
|
SERVICE_ERROR_NORMAL, // Error control type
|
||||||
szPath, // Service's binary
|
path.c_str(), // Service's binary
|
||||||
NULL, // No load ordering group
|
NULL, // No load ordering group
|
||||||
NULL, // No tag identifier
|
NULL, // No tag identifier
|
||||||
pszDependencies, // Dependencies
|
pszDependencies, // Dependencies
|
||||||
|
@ -92,7 +98,7 @@ std::string InstallService(PSTR pszServiceName,
|
||||||
);
|
);
|
||||||
if (schService == NULL)
|
if (schService == NULL)
|
||||||
{
|
{
|
||||||
ret = "CreateService failed";
|
ret = "CreateService failed";
|
||||||
goto Cleanup;
|
goto Cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +118,7 @@ Cleanup:
|
||||||
schService = NULL;
|
schService = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue