don't refresh progress counters pointlessly

the mainloop-based refresh timer keeps spinning even if there is no
update. overload stats_steps to signal whether a refresh is needed.

amends 8fbc4323.
This commit is contained in:
Oswald Buddenhagen 2022-07-04 18:03:24 +02:00
parent 460bfbb8ac
commit b9a4746b54

View File

@ -43,10 +43,12 @@ print_stats( void )
static void static void
stats_timeout( void *aux ATTR_UNUSED ) stats_timeout( void *aux ATTR_UNUSED )
{ {
if (stats_steps != -1) {
stats_steps = -1; stats_steps = -1;
conf_wakeup( &stats_wakeup, 200 );
print_stats(); print_stats();
} }
conf_wakeup( &stats_wakeup, 200 );
}
void void
stats( void ) stats( void )
@ -55,8 +57,10 @@ stats( void )
return; return;
// If the main loop appears to be running, skip the sync path. // If the main loop appears to be running, skip the sync path.
if (stats_steps < 0) if (stats_steps < 0) {
stats_steps = -2;
return; return;
}
// Rate-limit the (somewhat) expensive timer queries. // Rate-limit the (somewhat) expensive timer queries.
if (++stats_steps < 10) if (++stats_steps < 10)