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
This commit is contained in:
parent
b9c8f4900c
commit
83158c6893
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user