diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2016-09-08 01:28:34 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2016-09-08 01:28:34 +0200 |
commit | 5d9deb77e9664cb173869e6d16f7faa117be6c55 (patch) | |
tree | 9e730770069e9a69dc4c4d1e56dae3da487f9cb9 | |
parent | 01b4c2a63dac5a244d20d3d06b44c4072227f19a (diff) | |
download | plan9front-5d9deb77e9664cb173869e6d16f7faa117be6c55.tar.xz |
kernel: make sure procalarm() remaining time doesnt become negative
-rw-r--r-- | sys/src/9/port/alarm.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/src/9/port/alarm.c b/sys/src/9/port/alarm.c index bd834cecc..233e88768 100644 --- a/sys/src/9/port/alarm.c +++ b/sys/src/9/port/alarm.c @@ -63,14 +63,20 @@ procalarm(ulong time) Proc **l, *f; ulong when, old; + when = MACHP(0)->ticks; old = up->alarm; - if(old) - old = tk2ms(old - MACHP(0)->ticks); + if(old) { + old -= when; + if((long)old > 0) + old = tk2ms(old); + else + old = 0; + } if(time == 0) { up->alarm = 0; return old; } - when = ms2tk(time)+MACHP(0)->ticks; + when += ms2tk(time); if(when == 0) when = 1; |