summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2012-06-04 18:02:09 +0000
committerdelphij <delphij@FreeBSD.org>2012-06-04 18:02:09 +0000
commit8c1e8547690a122e46ea46591307ded406f3f72b (patch)
tree6ea24687d5adc49672fbd6b7bf0a602f3358bbad
parent975500b6892a5e2459c8cb404a6af18ff75ddbb6 (diff)
downloadFreeBSD-src-8c1e8547690a122e46ea46591307ded406f3f72b.zip
FreeBSD-src-8c1e8547690a122e46ea46591307ded406f3f72b.tar.gz
Replace the use of wall clock time with monotonically increasing
clock. In general, gettimeofday() is not appropriate interface when accounting for elasped time because it can go backward, in which case the policy code could errornously consider the limit as exceeded. MFC after: 1 week Reported by: Mahesh Arumugam Submitted by: Dorr H. Clark via gnn Sponsored by: Citrix / NetScaler
-rw-r--r--usr.sbin/inetd/inetd.c6
-rw-r--r--usr.sbin/inetd/inetd.h2
2 files changed, 4 insertions, 4 deletions
diff --git a/usr.sbin/inetd/inetd.c b/usr.sbin/inetd/inetd.c
index 7dc77b3..6b28764 100644
--- a/usr.sbin/inetd/inetd.c
+++ b/usr.sbin/inetd/inetd.c
@@ -688,11 +688,11 @@ main(int argc, char **argv)
*/
if (dofork) {
if (sep->se_count++ == 0)
- (void)gettimeofday(&sep->se_time, (struct timezone *)NULL);
+ (void)clock_gettime(CLOCK_MONOTONIC_FAST, &sep->se_time);
else if (toomany > 0 && sep->se_count >= toomany) {
- struct timeval now;
+ struct timespec now;
- (void)gettimeofday(&now, (struct timezone *)NULL);
+ (void)clock_gettime(CLOCK_MONOTONIC_FAST, &now);
if (now.tv_sec - sep->se_time.tv_sec >
CNT_INTVL) {
sep->se_time = now;
diff --git a/usr.sbin/inetd/inetd.h b/usr.sbin/inetd/inetd.h
index e0a83bd..06600f8 100644
--- a/usr.sbin/inetd/inetd.h
+++ b/usr.sbin/inetd/inetd.h
@@ -109,7 +109,7 @@ struct servtab {
u_int se_rpc_lowvers; /* RPC low version */
u_int se_rpc_highvers; /* RPC high version */
int se_count; /* number started since se_time */
- struct timeval se_time; /* start of se_count */
+ struct timespec se_time; /* start of se_count */
struct servtab *se_next;
struct se_flags {
u_int se_nomapped : 1;
OpenPOWER on IntegriCloud