summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorcheloha <cheloha@cvs.openbsd.org>2020-03-20 04:11:06 +0000
committercheloha <cheloha@cvs.openbsd.org>2020-03-20 04:11:06 +0000
commit0f4f8fa9ddaf4a8eb061adac38e0691fff75d1b3 (patch)
treee418bcef33877d175ed4a0b2ba7caa32b388895f /sys/kern
parentcbe45a968b2763560533629933fd933d7b011e3e (diff)
poll(2), ppoll(2), pselect(2), select(2): tsleep(9) -> tsleep_nsec(9)
With input from visa@. ok visa@
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/sys_generic.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c
index eb021208d0f..477d8a433d4 100644
--- a/sys/kern/sys_generic.c
+++ b/sys/kern/sys_generic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_generic.c,v 1.130 2020/02/14 14:32:44 mpi Exp $ */
+/* $OpenBSD: sys_generic.c,v 1.131 2020/03/20 04:11:05 cheloha Exp $ */
/* $NetBSD: sys_generic.c,v 1.24 1996/03/29 00:25:32 cgd Exp $ */
/*
@@ -587,7 +587,8 @@ dopselect(struct proc *p, int nd, fd_set *in, fd_set *ou, fd_set *ex,
fd_mask bits[6];
fd_set *pibits[3], *pobits[3];
struct timespec elapsed, start, stop;
- int s, ncoll, error = 0, timo;
+ uint64_t nsecs;
+ int s, ncoll, error = 0;
u_int ni;
if (nd < 0)
@@ -642,16 +643,18 @@ retry:
if (error || *retval)
goto done;
if (timeout == NULL || timespecisset(timeout)) {
- timo = (timeout == NULL) ? 0 : tstohz(timeout);
- if (timeout != NULL)
+ if (timeout != NULL) {
getnanouptime(&start);
+ nsecs = MIN(TIMESPEC_TO_NSEC(timeout), MAXTSLP);
+ } else
+ nsecs = INFSLP;
s = splhigh();
if ((p->p_flag & P_SELECT) == 0 || nselcoll != ncoll) {
splx(s);
goto retry;
}
atomic_clearbits_int(&p->p_flag, P_SELECT);
- error = tsleep(&selwait, PSOCK | PCATCH, "select", timo);
+ error = tsleep_nsec(&selwait, PSOCK | PCATCH, "select", nsecs);
splx(s);
if (timeout != NULL) {
getnanouptime(&stop);
@@ -916,7 +919,8 @@ doppoll(struct proc *p, struct pollfd *fds, u_int nfds,
size_t sz;
struct pollfd pfds[4], *pl = pfds;
struct timespec elapsed, start, stop;
- int timo, ncoll, i, s, error;
+ uint64_t nsecs;
+ int ncoll, i, s, error;
/* Standards say no more than MAX_OPEN; this is possibly better. */
if (nfds > min((int)lim_cur(RLIMIT_NOFILE), maxfiles))
@@ -950,16 +954,18 @@ retry:
if (*retval)
goto done;
if (timeout == NULL || timespecisset(timeout)) {
- timo = (timeout == NULL) ? 0 : tstohz(timeout);
- if (timeout != NULL)
+ if (timeout != NULL) {
getnanouptime(&start);
+ nsecs = MIN(TIMESPEC_TO_NSEC(timeout), MAXTSLP);
+ } else
+ nsecs = INFSLP;
s = splhigh();
if ((p->p_flag & P_SELECT) == 0 || nselcoll != ncoll) {
splx(s);
goto retry;
}
atomic_clearbits_int(&p->p_flag, P_SELECT);
- error = tsleep(&selwait, PSOCK | PCATCH, "poll", timo);
+ error = tsleep_nsec(&selwait, PSOCK | PCATCH, "poll", nsecs);
splx(s);
if (timeout != NULL) {
getnanouptime(&stop);