]> git.ipfire.org Git - fireperf.git/commitdiff
server: Prevent useless stats printed when called too soon
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 29 Jan 2021 17:21:25 +0000 (17:21 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 29 Jan 2021 17:21:25 +0000 (17:21 +0000)
Sometimes the timer event gets stuck in the queue and we would be called
multiple times in a row. To prevent printing any useless output, we just
ignore any calls that were too soon.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/server.c

index 33ad3130a0a0895a7d01dfb175e52aece2ae1a68..0dbce224d7f76b75a974a893c03a7f4e13fe5825 100644 (file)
@@ -131,6 +131,10 @@ static int dump_stats(struct fireperf_config* conf, struct fireperf_server_stats
 
        double delta = timespec_delta(&now, &stats->last_printed);
 
+       // Called too soon again?
+       if (delta < 0.1)
+               return 0;
+
        // Format timestamp
        const char* timestamp = format_timespec(&now);