--- libaitsched/src/hooks.c 2023/07/27 20:51:28 1.41 +++ libaitsched/src/hooks.c 2023/08/17 14:14:24 1.42 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: hooks.c,v 1.41 2023/07/27 20:51:28 misho Exp $ +* $Id: hooks.c,v 1.42 2023/08/17 14:14:24 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -1385,7 +1385,11 @@ sched_hook_fetch(void *root, void *arg __unused) if (TAILQ_FIRST(&r->root_timer)) { m = r->root_wait; sched_timespecsub(&m, &now, &mtmp); - r->root_wait = mtmp; + if (mtmp.tv_sec < 0 || mtmp.tv_nsec < 0) + /* don't wait for events. we have ready timer */ + sched_timespecclear(&r->root_wait); + else + r->root_wait = mtmp; } else { /* set wait INFTIM */ sched_timespecinf(&r->root_wait); @@ -1396,7 +1400,11 @@ sched_hook_fetch(void *root, void *arg __unused) m = TASK_TS(task); sched_timespecsub(&m, &now, &mtmp); - r->root_wait = mtmp; + if (mtmp.tv_sec < 0 || mtmp.tv_nsec < 0) + /* don't wait for events. we have ready timer */ + sched_timespecclear(&r->root_wait); + else + r->root_wait = mtmp; } else { /* set wait INFTIM */ sched_timespecinf(&r->root_wait);