1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-22 19:23:31 +00:00

1. Fixed bug where Windows Terminal doesn't work when on battery power

2. Added logging for timers
This commit is contained in:
Bryan Roe
2020-12-30 14:05:49 -08:00
parent 4005cf3aa1
commit f28e7b072b
4 changed files with 44 additions and 7 deletions

View File

@@ -3567,6 +3567,14 @@ void MeshServer_ConnectEx(MeshAgentHostContainer *agent)
parser_result *rs;
parser_result_field *f;
if (agent->timerLogging != 0 && agent->retryTimerSet != 0)
{
agent->retryTimerSet = 0;
ILIBLOGMESSAGEX(" >> Retry Timer Elapsed [serverConnectionState: %d, chainState: %d]", agent->serverConnectionState, ILibIsChainBeingDestroyed(agent->chain));
}
// If this is called while we are in any connection state, just leave now.
if (agent->serverConnectionState != 0) return;
@@ -3941,7 +3949,7 @@ void MeshServer_Connect(MeshAgentHostContainer *agent)
agent->fakeUpdate = ILibSimpleDataStore_Get(agent->masterDb, "fakeUpdate", NULL, 0);
agent->controlChannelDebug = ILibSimpleDataStore_Get(agent->masterDb, "controlChannelDebug", NULL, 0);
ILibDuktape_HECI_Debug = (ILibSimpleDataStore_Get(agent->masterDb, "heciDebug", NULL, 0) != 0);
agent->timerLogging = ILibSimpleDataStore_Get(agent->masterDb, "timerLogging", NULL, 0);
#if defined(_LINKVM) && defined(_POSIX) && !defined(__APPLE__)
SLAVELOG = ILibSimpleDataStore_Get(agent->masterDb, "slaveKvmLog", NULL, 0);
@@ -3976,6 +3984,7 @@ void MeshServer_Connect(MeshAgentHostContainer *agent)
delay = agent->retryTime + (timeout % agent->retryTime); // Random value between current value and double the current value
}
printf("AutoRetry Connect in %d milliseconds\n", delay);
if (agent->timerLogging != 0) { ILIBLOGMESSAGEX(" >> Retry Timer set for %d milliseconds", delay); agent->retryTimerSet = 1; }
ILibLifeTime_AddEx(ILibGetBaseTimer(agent->chain), agent, delay, (ILibLifeTime_OnCallback)MeshServer_ConnectEx, NULL);
agent->retryTime = delay;
}

View File

@@ -224,6 +224,8 @@ typedef struct MeshAgentHostContainer
char agentNonce[UTIL_SHA384_HASHSIZE];
int serverAuthState;
int timerLogging;
int retryTimerSet;
int controlChannel_idleTimeout_seconds;
int controlChannel_idleTimeout_dataMode;
char g_selfid[UTIL_SHA384_HASHSIZE];

File diff suppressed because one or more lines are too long

View File

@@ -96,14 +96,40 @@ function dispatch(options)
}
parms += ('/TR "\\"' + process.execPath + '\\" -b64exec ' + str + '"');
var child = require('child_process').execFile(process.env['windir'] + '\\system32\\cmd.exe', [parms]);
child.stderr.on('data', function (c) { });
child.stdout.on('data', function (c) { });
child.waitExit();
var taskoptions = { env: { _target: process.execPath, _args: '-b64exec ' + str, _user: options.user } };
for (var c1e in process.env)
{
taskoptions.env[c1e] = process.env[c1e];
}
var child = require('child_process').execFile(process.env['windir'] + '\\system32\\cmd.exe', ['cmd']);
var child = require('child_process').execFile(process.env['windir'] + '\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', ['powershell', '-noprofile', '-nologo', '-command', '-'], taskoptions);
child.stderr.on('data', function (c) { });
child.stdout.on('data', function (c) { });
child.stdin.write('SCHTASKS /CREATE /F /TN MeshUserTask /SC ONCE /ST 00:00 ');
if (options.user)
{
child.stdin.write('/RU $env:_user ');
}
else
{
if (require('user-sessions').getProcessOwnerName(process.pid).tsid == 0)
{
// LocalSystem
child.stdin.write('/RU SYSTEM ');
}
}
child.stdin.write('/TR "$env:_target $env:_args"\r\n');
child.stdin.write('$ts = New-Object -ComObject Schedule.service\r\n');
child.stdin.write('$ts.connect()\r\n');
child.stdin.write('$tsfolder = $ts.getfolder("\\")\r\n');
child.stdin.write('$task = $tsfolder.GetTask("MeshUserTask")\r\n');
child.stdin.write('$taskdef = $task.Definition\r\n');
child.stdin.write('$taskdef.Settings.StopIfGoingOnBatteries = $false\r\n');
child.stdin.write('$taskdef.Settings.DisallowStartIfOnBatteries = $false\r\n');
child.stdin.write('$taskdef.Actions.Item(1).Path = $env:_target\r\n');
child.stdin.write('$taskdef.Actions.Item(1).Arguments = $env:_args\r\n');
child.stdin.write('$tsfolder.RegisterTaskDefinition($task.Name, $taskdef, 4, $null, $null, $null)\r\n');
child.stdin.write('SCHTASKS /RUN /TN MeshUserTask\r\n');
child.stdin.write('SCHTASKS /DELETE /F /TN MeshUserTask\r\nexit\r\n');