From: Alan T. DeKok Date: Fri, 6 Dec 2019 17:37:27 +0000 (-0500) Subject: skip timer if we are not getting a response X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=443032c254f457f2cc1cbd1a63efecb347cd0d77;p=thirdparty%2Ffreeradius-server.git skip timer if we are not getting a response --- diff --git a/src/lib/io/load.c b/src/lib/io/load.c index b4979d2452e..a6d33018008 100644 --- a/src/lib/io/load.c +++ b/src/lib/io/load.c @@ -168,15 +168,24 @@ static void load_timer(fr_event_list_t *el, fr_time_t now, void *uctx) } /* - * Update the "next" timer to the correct value, no - * matter what. + * Skip timers if we're too busy. */ l->next += l->delta; - if (l->next <= now) { - delta = 0; - fprintf(stderr, "."); - } else { - delta = l->next - now; + if (l->next < now) { + while ((l->next + l->delta) < now) { + l->next += l->delta; + } + } + delta = l->next - now; + + /* + * Track packets/s. Since times are in nanoseconds, we + * have to scale the counters up by NSEC. And since NSEC + * is 1B, the calculations have to be done via 64-bit + * numbers, and then converted to a final 32-bit counter. + */ + if (now > l->step_start) { + l->stats.pps_accepted = (((uint64_t) (l->stats.received - l->step_received)) * NSEC) / (now - l->step_start); } /*