diff options
author | sam <sam@FreeBSD.org> | 2003-02-26 17:16:38 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2003-02-26 17:16:38 +0000 |
commit | ebbf7468f1403db9c710d85eca100eee6667141c (patch) | |
tree | 6110abcff9bd305d14773afd3c594ccf9260cc74 /sys/kern/kern_time.c | |
parent | 65117bb4c9360c8a3d5fa0970b48537d33d636d4 (diff) | |
download | FreeBSD-src-ebbf7468f1403db9c710d85eca100eee6667141c.zip FreeBSD-src-ebbf7468f1403db9c710d85eca100eee6667141c.tar.gz |
o fix ppsratecheck to interpret a maxpps of zero as "ignore everything"
o add a comment explaining the significance of using 0 or -1 (actually
any negative value) for maxpps
Diffstat (limited to 'sys/kern/kern_time.c')
-rw-r--r-- | sys/kern/kern_time.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 9cca995..6a046fa 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -679,6 +679,10 @@ ratecheck(struct timeval *lasttime, const struct timeval *mininterval) * Return 0 if the limit is to be enforced (e.g. the caller * should drop a packet because of the rate limitation). * + * maxpps of 0 always causes zero to be returned. maxpps 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. @@ -697,7 +701,7 @@ ppsratecheck(struct timeval *lasttime, int *curpps, int maxpps) if (lasttime->tv_sec == 0 || (u_int)(now - lasttime->tv_sec) >= hz) { lasttime->tv_sec = now; *curpps = 1; - return (1); + return (maxpps != 0); } else { (*curpps)++; /* NB: ignore potential overflow */ return (maxpps < 0 || *curpps < maxpps); |