]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Better fix for fixed point computations
authorAlan T. DeKok <aland@freeradius.org>
Tue, 21 Feb 2012 17:07:23 +0000 (18:07 +0100)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 21 Feb 2012 17:07:23 +0000 (18:07 +0100)
So if rate_pps < 1000, we can still count it.

src/main/process.c

index b4d800b3d84a934d5394c5f5d0c32a0e59364a44..1eaecc2b68ed88f5713c0663c0613316204a1808 100644 (file)
@@ -1334,9 +1334,9 @@ int request_receive(rad_listen_t *listener, RADIUS_PACKET *packet,
                pps = USEC - now.tv_usec;
                pps /= 1000;               /* now 0..9999 */
                pps *= sock->rate_pps_old; /* capped at 1000000 */
-               pps /= 1000;
 
-               pps += sock->rate_pps_now;
+               pps += sock->rate_pps_now * 1000;
+               pps /= 1000;
 
                if (pps > sock->max_rate) {
                        DEBUG("Dropping request due to rate limiting");