Moved $graceline definition up, fixing a bug; made peers checking msgs more informative

This commit is contained in:
pezcurrel 2022-12-26 15:01:35 +01:00
parent 97f5b99654
commit 3f7a5ff69c

View file

@ -202,12 +202,12 @@ if ($res===false) mexit(3,'couldnt set «utf8mb4» charset for MySQL: '.mysql
$deadinsts=[];
if ($opts['excludedead']) {
$graceline=time()-$opts['gracetime'];
$res=myq($link,'SELECT URI FROM Instances WHERE LastOkCheckTS<'.$graceline.' OR (LastOkCheckTS IS NULL AND InsertTS<'.$graceline.')');
lecho(0,'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'];
$graceline=time()-$opts['gracetime'];
$res=myq($link,'SELECT Hostname FROM Peers WHERE LastOkCheckTS<'.$graceline.' OR (LastOkCheckTS IS NULL AND FirstCheckTS<'.$graceline.')');
lecho(0,'got '.mysqli_num_rows($res).' dead instances from Peers table.'.N);
while ($row=mysqli_fetch_assoc($res))
@ -296,11 +296,12 @@ function crawl($list,$id) {
$newc++;
}
}
$cp=0;
$cp=count($peers);
$pi=0;
foreach ($peers as $peer) {
$cp++;
$pi++;
if (!is_string($peer)) {
lecho(2,'$peers, entity '.$cp.' is not a string.'.N);
lecho(2,'$peers, entity '.$pi.'/'.$cp.' is not a string.'.N);
} else {
if (!in_array($peer,$ainsts)) {
$ainsts[]=$peer;
@ -314,9 +315,9 @@ function crawl($list,$id) {
if (in_array($peer,$nlist)) $whynot[]='it has already been added to next round list';
if ($opts['excludedead'] && in_array($peer,$deadinsts)) $whynot[]='its dead';
if (count($whynot)>0) {
lecho(0,'not adding peer «'.$peer. to next round list because '.implode(', ',$whynot).'.'.N);
lecho(0,'«'.$inst.'»: not adding peer «'.$peer. ('.$pi.'/'.$cp.') to next round list because '.implode(', ',$whynot).'.'.N);
} else {
lecho(1,'adding peer «'.$peer. to next round list :-)'.N);
lecho(1,'«'.$inst.'»: adding peer «'.$peer. ('.$pi.'/'.$cp.') to next round list :-)'.N);
$nlist[]=$peer;
}
}