summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@home.transmeta.com>2003-03-09 02:48:06 -0800
committerLinus Torvalds <torvalds@home.transmeta.com>2003-03-09 02:48:06 -0800
commitd1537fd1c7a1fa9303467825eb5a764cb229df10 (patch)
tree8a9ffccc0bd03e5db023c56484f9dcdf0e54e45d
parent063b14876a1ce849ca7e1dd4c8b8b0c06a35defb (diff)
Fix nanosleep() problem noticed by Todd Mokros <tmokros@neo.rr.com>.
If we raced on a timer expire, we'd get a negative timeout and think that is was a _huge_ positive timeout.
-rw-r--r--kernel/posix-timers.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
index add2e8abd710..19e2aa5dcb41 100644
--- a/kernel/posix-timers.c
+++ b/kernel/posix-timers.c
@@ -1273,7 +1273,7 @@ do_clock_nanosleep(clockid_t which_clock, int flags, struct timespec *tsave)
spin_unlock_irq(&nanosleep_abs_list_lock);
}
if (active) {
- unsigned long jiffies_f = jiffies;
+ long jiffies_left;
/*
* Always restart abs calls from scratch to pick up any
@@ -1282,7 +1282,12 @@ do_clock_nanosleep(clockid_t which_clock, int flags, struct timespec *tsave)
if (abs)
return -ERESTARTNOHAND;
- jiffies_to_timespec(new_timer.expires - jiffies_f, tsave);
+ jiffies_left = new_timer.expires - jiffies;
+
+ if (jiffies_left < 0)
+ return 0;
+
+ jiffies_to_timespec(jiffies_left, tsave);
while (tsave->tv_nsec < 0) {
tsave->tv_nsec += NSEC_PER_SEC;