MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ratecheck

Function ratecheck

freebsd/kern/kern_time.c:1025–1046  ·  view source on GitHub ↗

* ratecheck(): simple time-based rate-limit checking. */

Source from the content-addressed store, hash-verified

1023 * ratecheck(): simple time-based rate-limit checking.
1024 */
1025int
1026ratecheck(struct timeval *lasttime, const struct timeval *mininterval)
1027{
1028 struct timeval tv, delta;
1029 int rv = 0;
1030
1031 getmicrouptime(&tv); /* NB: 10ms precision */
1032 delta = tv;
1033 timevalsub(&delta, lasttime);
1034
1035 /*
1036 * check for 0,0 is so that the message will be seen at least once,
1037 * even if interval is huge.
1038 */
1039 if (timevalcmp(&delta, mininterval, >=) ||
1040 (lasttime->tv_sec == 0 && lasttime->tv_usec == 0)) {
1041 *lasttime = tv;
1042 rv = 1;
1043 }
1044
1045 return (rv);
1046}
1047
1048/*
1049 * ppsratecheck(): packets (or events) per second limitation.

Callers 11

uipc_socket.cFile · 0.70
hwmp_send_preqFunction · 0.50
hwmp_send_perrFunction · 0.50
in_pcbinslbgrouphashFunction · 0.50
ip_mdqFunction · 0.50
igmp_input_v3_queryFunction · 0.50
get_pv_entryFunction · 0.50
mld_v2_input_queryFunction · 0.50
get_pv_entryFunction · 0.50
crypto_ioctlFunction · 0.50
zone_log_warningFunction · 0.50

Calls 2

getmicrouptimeFunction · 0.85
timevalsubFunction · 0.70

Tested by

no test coverage detected