Page MenuHomeFreeBSD

D34981.diff
No OneTemporary

D34981.diff

diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -1258,15 +1258,13 @@
struct sigacts *ps;
sigset_t saved_mask, new_block;
struct proc *p;
- int error, sig, timo, timevalid = 0;
- struct timespec rts, ets, ts;
- struct timeval tv;
+ int error, sig, timevalid = 0;
+ sbintime_t sbt, precision, tsbt;
+ struct timespec ts;
bool traced;
p = td->td_proc;
error = 0;
- ets.tv_sec = 0;
- ets.tv_nsec = 0;
traced = false;
/* Ensure the sigfastblock value is up to date. */
@@ -1275,10 +1273,19 @@
if (timeout != NULL) {
if (timeout->tv_nsec >= 0 && timeout->tv_nsec < 1000000000) {
timevalid = 1;
- getnanouptime(&rts);
- timespecadd(&rts, timeout, &ets);
+ ts = *timeout;
+ if (ts.tv_sec < INT32_MAX / 2) {
+ tsbt = tstosbt(ts);
+ precision = tsbt;
+ precision >>= tc_precexp;
+ if (TIMESEL(&sbt, tsbt))
+ sbt += tc_tick_sbt;
+ sbt += tsbt;
+ } else
+ precision = sbt = 0;
}
- }
+ } else
+ precision = sbt = 0;
ksiginfo_init(ksi);
/* Some signals can not be waited for. */
SIG_CANTMASK(waitset);
@@ -1312,21 +1319,9 @@
* POSIX says this must be checked after looking for pending
* signals.
*/
- if (timeout != NULL) {
- if (!timevalid) {
- error = EINVAL;
- break;
- }
- getnanouptime(&rts);
- if (timespeccmp(&rts, &ets, >=)) {
- error = EAGAIN;
- break;
- }
- timespecsub(&ets, &rts, &ts);
- TIMESPEC_TO_TIMEVAL(&tv, &ts);
- timo = tvtohz(&tv);
- } else {
- timo = 0;
+ if (timeout != NULL && !timevalid) {
+ error = EINVAL;
+ break;
}
if (traced) {
@@ -1334,17 +1329,13 @@
break;
}
- error = msleep(&p->p_sigacts, &p->p_mtx, PPAUSE | PCATCH,
- "sigwait", timo);
+ error = msleep_sbt(&p->p_sigacts, &p->p_mtx, PPAUSE | PCATCH,
+ "sigwait", sbt, precision, C_ABSOLUTE);
/* The syscalls can not be restarted. */
if (error == ERESTART)
error = EINTR;
- /* We will calculate timeout by ourself. */
- if (timeout != NULL && error == EAGAIN)
- error = 0;
-
/*
* If PTRACE_SCE or PTRACE_SCX were set after
* userspace entered the syscall, return spurious

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 15, 10:57 PM (21 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15421351
Default Alt Text
D34981.diff (2 KB)

Event Timeline