Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Feb 2023 19:27:04 GMT
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 83158c68934b - main - time: s/ppsratecheck/eventratecheck
Message-ID:  <202302241927.31OJR4w1066942@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by mjg:

URL: https://cgit.FreeBSD.org/src/commit/?id=83158c68934b4fae6897bbe1694cf9a7f4b9c0b1

commit 83158c68934b4fae6897bbe1694cf9a7f4b9c0b1
Author:     Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2023-02-23 12:49:11 +0000
Commit:     Mateusz Guzik <mjg@FreeBSD.org>
CommitDate: 2023-02-24 19:26:36 +0000

    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
---
 sys/kern/kern_time.c | 18 +++++++++---------
 sys/sys/time.h       |  3 ++-
 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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202302241927.31OJR4w1066942>