GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
RATECHECK(9) FreeBSD Kernel Developer's Manual RATECHECK(9)

ratecheck, ppsratecheck
event rate limiting

#include <sys/time.h>

int
ratecheck(struct timeval *lasttime, struct timeval *mininterval);

int
ppsratecheck(struct timeval *lasttime, int *curpps, int maxpps);

The ratecheck and ppsratecheck functions facilitate rate-limiting of arbitrary events. The former enforces a minimum interval between events while the latter enforces a maximum number of events per second.

The ratecheck function compares the current time to the value pointed to by lasttime. If the difference is equal to or greater than mininterval, it returns a non-zero value and updates lasttime to the current time. Otherwise, it returns zero.

The ppsratecheck function first compares the current time to lasttime. If at least a full second has passed, the value pointed to by the curpps argument is reset to 1 and lasttime is updated to the current time. Otherwise, curpps is incremented and lasttime is left untouched. In either case, ppsratecheck returns a non-zero value if and only if the updated curpps is less than or equal to maxpps or maxpps is negative.

counter(9)

The ratecheck and ppsratecheck functions first appeared in FreeBSD 5.1.
September 25, 2017 FreeBSD 13.1-RELEASE

Search for    or go to Top of page |  Section 9 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.