aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2023-02-23 12:49:11 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2023-02-24 19:26:36 +0000
commit83158c68934b4fae6897bbe1694cf9a7f4b9c0b1 (patch)
tree6977056e0b9f89ead24ffa8c402d5906918f1901
parentb9c8f4900ce7a18508517ce74a3e644a5ae3c1bd (diff)
downloadsrc-83158c68934b4fae6897bbe1694cf9a7f4b9c0b1.tar.gz
src-83158c68934b4fae6897bbe1694cf9a7f4b9c0b1.zip
time: s/ppsratecheck/eventratecheck
The routine is used as a general event-limiting routine in places which have nothing to do with packets. Provide a define to keep everything happy. Reviewed by: rew Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D38746
-rw-r--r--sys/kern/kern_time.c18
-rw-r--r--sys/sys/time.h3
2 files changed, 11 insertions, 10 deletions
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index 658f6df0b386..fd4e89d61b15 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -1098,21 +1098,21 @@ ratecheck(struct timeval *lasttime, const struct timeval *mininterval)
}
/*
- * ppsratecheck(): packets (or events) per second limitation.
+ * eventratecheck(): events per second limitation.
*
* Return 0 if the limit is to be enforced (e.g. the caller
- * should drop a packet because of the rate limitation).
+ * should ignore the event because of the rate limitation).
*
- * maxpps of 0 always causes zero to be returned. maxpps of -1
+ * maxeps of 0 always causes zero to be returned. maxeps of -1
* always causes 1 to be returned; this effectively defeats rate
* limiting.
*
* Note that we maintain the struct timeval for compatibility
* with other bsd systems. We reuse the storage and just monitor
- * clock ticks for minimal overhead.
+ * clock ticks for minimal overhead.
*/
int
-ppsratecheck(struct timeval *lasttime, int *curpps, int maxpps)
+eventratecheck(struct timeval *lasttime, int *cureps, int maxeps)
{
int now;
@@ -1124,11 +1124,11 @@ ppsratecheck(struct timeval *lasttime, int *curpps, int maxpps)
now = ticks;
if (lasttime->tv_sec == 0 || (u_int)(now - lasttime->tv_sec) >= hz) {
lasttime->tv_sec = now;
- *curpps = 1;
- return (maxpps != 0);
+ *cureps = 1;
+ return (maxeps != 0);
} else {
- (*curpps)++; /* NB: ignore potential overflow */
- return (maxpps < 0 || *curpps <= maxpps);
+ (*cureps)++; /* NB: ignore potential overflow */
+ return (maxeps < 0 || *cureps <= maxeps);
}
}
diff --git a/sys/sys/time.h b/sys/sys/time.h
index 20375b9a82af..673de65a688c 100644
--- a/sys/sys/time.h
+++ b/sys/sys/time.h
@@ -578,7 +578,8 @@ void getboottimebin(struct bintime *boottimebin);
/* Other functions */
int itimerdecr(struct itimerval *itp, int usec);
int itimerfix(struct timeval *tv);
-int ppsratecheck(struct timeval *, int *, int);
+int eventratecheck(struct timeval *, int *, int);
+#define ppsratecheck(t, c, m) eventratecheck(t, c, m)
int ratecheck(struct timeval *, const struct timeval *);
void timevaladd(struct timeval *t1, const struct timeval *t2);
void timevalsub(struct timeval *t1, const struct timeval *t2);