alarm: skip timed out alarms when inserting in procalarm() (thanks erik)
from erik quanstros 9fans post: i think the list insertion code needs a single-read test that f->alarm != 0. to prevent the 0 from acting like a fencepost. e.g. trying to insert -10 into list -40 -30 0 -20. if(alarms.head) { l = &alarms.head; for(f = *l; f; f = f->palarm) { >> fw = f->alarm; >> if(fw != 0 && (long)(fw - when) >= 0) { up->palarm = f; *l = up; goto done; } l = &f->palarm; } *l = up; }
This commit is contained in:
parent
d1be5e163c
commit
8ebe3f680e
1 changed files with 2 additions and 1 deletions
|
@ -88,7 +88,8 @@ procalarm(ulong time)
|
||||||
if(alarms.head) {
|
if(alarms.head) {
|
||||||
l = &alarms.head;
|
l = &alarms.head;
|
||||||
for(f = *l; f; f = f->palarm) {
|
for(f = *l; f; f = f->palarm) {
|
||||||
if((long)(f->alarm - when) >= 0) {
|
time = f->alarm;
|
||||||
|
if(time != 0 && (long)(time - when) >= 0) {
|
||||||
up->palarm = f;
|
up->palarm = f;
|
||||||
*l = up;
|
*l = up;
|
||||||
goto done;
|
goto done;
|
||||||
|
|
Loading…
Reference in a new issue