Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern PR/8657: z%rentaboat.se@localhost: alarm takes more seconds t...



details:   https://anonhg.NetBSD.org/src/rev/85ce0676415e
branches:  trunk
changeset: 517437:85ce0676415e
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Nov 13 00:34:21 2001 +0000

description:
PR/8657: z%rentaboat.se@localhost: alarm takes more seconds that it can handle.

This is a followup to PR/14558.

    - itimerfix(9) limited the number of seconds to 100M, before I changed
      it to 1000M for PR/14558.
    - nanosleep(2) documents a limit of 1000M seconds.
    - setitimer(2), select(2), and other library functions that indirectly
      use setitimer(2) for example alarm(3) don't specify a limit.

So it only seems appropriate that any positive number of seconds in
struct timeval should be accepted by any code that uses itimerfix(9)
directly, except nanosleep(2) which should check for 1000M seconds
manually. This changes makes the manual pages of select(2), nanosleep(2),
setitimer(2), and alarm(3) consistent with the code.

diffstat:

 sys/kern/kern_time.c |  9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diffs (37 lines):

diff -r f554a48e3b65 -r 85ce0676415e sys/kern/kern_time.c
--- a/sys/kern/kern_time.c      Tue Nov 13 00:32:34 2001 +0000
+++ b/sys/kern/kern_time.c      Tue Nov 13 00:34:21 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_time.c,v 1.58 2001/11/12 15:25:18 lukem Exp $     */
+/*     $NetBSD: kern_time.c,v 1.59 2001/11/13 00:34:21 christos Exp $  */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.58 2001/11/12 15:25:18 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.59 2001/11/13 00:34:21 christos Exp $");
 
 #include "fs_nfs.h"
 #include "opt_nfs.h"
@@ -273,7 +273,7 @@
                return (error);
 
        TIMESPEC_TO_TIMEVAL(&atv,&rqt)
-       if (itimerfix(&atv))
+       if (itimerfix(&atv) || atv.tv_sec > 1000000000)
                return (EINVAL);
 
        s = splclock();
@@ -646,8 +646,7 @@
        struct timeval *tv;
 {
 
-       if (tv->tv_sec < 0 || tv->tv_sec > 1000000000 ||
-           tv->tv_usec < 0 || tv->tv_usec >= 1000000)
+       if (tv->tv_sec < 0 || tv->tv_usec < 0 || tv->tv_usec >= 1000000)
                return (EINVAL);
        if (tv->tv_sec == 0 && tv->tv_usec != 0 && tv->tv_usec < tick)
                tv->tv_usec = tick;



Home | Main Index | Thread Index | Old Index