RATECHECK(9)

πŸ“¦
version 15.1 Β· 3 versions
, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸ’– RATECHECK(9) β€” event rate limiting, bestie πŸ’–

Hiii! Welcome to the Kernel Developer's Manual, RATECHECK(9) edition. This page is all about ratecheck and ppsratecheck, aka your rate-limiting duo. It's giving "please don't let your events do too much too fast" energy, and honestly? Obsessed. πŸ’…


🌸 NAME 🌸

ratecheck, ppsratecheck β€” event rate limiting. Yes bestie, both of them, same iconic mission. ✨

πŸŽ€ SYNOPSIS πŸŽ€

#include <sys/time.h>

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

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

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so the ratecheck and ppsratecheck functions are literally here to 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. Two different girlies, two different jobs, both slaying. πŸ’–

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. No cap, that's the whole vibe check. ✨

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. Periodt. πŸ’…

🌈 SEE ALSO 🌈

πŸ‘‘ HISTORY πŸ‘‘

The ratecheck and ppsratecheck functions first appeared in FreeBSD 5.1. Iconic behavior, honestly. 🫢


Mwah πŸ’‹ this page came from Debian, dated March 11, 2022, and it's RATECHECK(9) β€” byeee bestie! πŸŽ€πŸ’–βœ¨

πŸ“¦ where this page comes from