Fixed “deadinsts” loading queries; changed default “conntimeout” and “functimeout”

This commit is contained in:
pezcurrel 2024-01-02 00:52:20 +01:00
parent 6c29f1e24e
commit 6914551daa

View file

@ -23,7 +23,7 @@ define('BNAME',preg_replace('/\.[^.]*$/','',SNAME));
require __DIR__.'/../lib/gurl.php';
require __DIR__.'/../lib/ghs.php';
require __DIR__.'/../lib/ght.php';
require __DIR__.'/../lib/gracetime.php';
require __DIR__.'/../lib/grace.php';
require __DIR__.'/../lib/parsetime.php';
use function mysqli_real_escape_string as myesc;
@ -35,8 +35,8 @@ $opts=[
'peersfp'=>__DIR__.'/peers.responding',
'ckpeersfp'=>__DIR__.'/peers.checked',
'excludefp'=>null,
'conntimeout'=>3,
'functimeout'=>5,
'conntimeout'=>4,
'functimeout'=>7,
'loop'=>false,
'excludedead'=>true,
'ignorelock'=>false,
@ -73,8 +73,8 @@ OPTIONS
how to specify time.
DEFAULT: '.ght($opts['gracetime'],null,0).'
-G, --graceline
Return the “graceline” (now - gracetime: see option above) in unix time and
local time, then exit.
Return the “graceline” (0:0:0 of today minus gracetime: see option above) in
unix time and local time, then exit.
-p, --peersfp <file>
Defines the file into which the ordered list of responding instances
will be saved.
@ -163,7 +163,6 @@ for ($i=1; $i<$argc; $i++) {
$i++;
$opts['minmsgimplev']=array_search(ucfirst(strtolower($argv[$i])),$msglevs);
} elseif ($argv[$i]=='-G' || $argv[$i]=='--graceline') {
$graceline=time()-$opts['gracetime'];
echo 'Graceline: '.$graceline.' ('.date('Y-m-d H:i:s',$graceline).').'.N;
exit(0);
} elseif ($argv[$i]=='-h' || $argv[$i]=='--help') {
@ -199,14 +198,14 @@ if ($res===false) mexit(3,'couldnt set «utf8mb4» charset for MySQL: '.mysql
$deadinsts=[];
if ($opts['excludedead']) {
$graceline=time()-$opts['gracetime'];
lecho(1,'loading dead instances from “Instances” and “Peers” table (gracetime: '.ght($opts['gracetime'],null,0).'; graceline: '.date('Y-m-d H:i:s',$graceline).').'.N);
$res=myq($link,'SELECT URI FROM Instances WHERE LastOkCheckTS<'.$graceline.' OR LastOkCheckTS IS NULL');
$res=myq($link,'SELECT URI FROM Instances WHERE LastOkCheckTS IS NULL OR LastOkCheckTS < '.$graceline);
lecho(1,'got '.mysqli_num_rows($res).' dead instances from “Instances” table.'.N);
while ($row=mysqli_fetch_assoc($res))
if (!in_array($row['URI'],$deadinsts))
$deadinsts[]=$row['URI'];
$res=myq($link,'SELECT Hostname FROM Peers WHERE LastOkCheckTS<'.$graceline.' OR LastOkCheckTS IS NULL');
// $res=myq($link,'SELECT Hostname FROM Peers WHERE LastOkCheckTS IS NULL OR (LastCheckTS-LastOkCheckTS < '.$gracetime.' AND (LastCheckTS-LastOkCheckTS) / (ChecksAtLast-ChecksAtLastOk) <= '.$graceminfreq.')');
$res=myq($link,'SELECT Hostname FROM Peers WHERE LastOkCheckTS IS NULL OR LastOkCheckTS < '.$graceline);
lecho(1,'got '.mysqli_num_rows($res).' dead instances from “Peers” table.'.N);
while ($row=mysqli_fetch_assoc($res))
if (!in_array($row['Hostname'],$deadinsts))
@ -214,7 +213,7 @@ if ($opts['excludedead']) {
unset($res,$row);
lecho(1,'loaded list of dead instances ('.count($deadinsts).').'.N);
}
//mexit(0,'bau!'.N,0,true);
//mexit(1,'bau!'.N,0,true);
$insts=[];
$ckinsts=[];