--- libaitsched/src/hooks.c 2012/05/10 14:44:22 1.5.2.3 +++ libaitsched/src/hooks.c 2012/05/10 15:30:18 1.5.2.4 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: hooks.c,v 1.5.2.3 2012/05/10 14:44:22 misho Exp $ +* $Id: hooks.c,v 1.5.2.4 2012/05/10 15:30:18 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -212,7 +212,7 @@ void * sched_hook_fetch(void *root, void *arg __unused) { sched_root_task_t *r = root; - sched_task_t *task; + sched_task_t *task, *tmp; struct timespec now, m, mtmp; struct timespec *timeout; struct kevent evt[1], res[KQ_EVENTS]; @@ -318,7 +318,7 @@ sched_hook_fetch(void *root, void *arg __unused) /* Put read/write task to ready queue */ switch (res[i].filter) { case EVFILT_READ: - TAILQ_FOREACH(task, &r->root_read, task_node) { + TAILQ_FOREACH_SAFE(task, &r->root_read, task_node, tmp) { if (TASK_FD(task) != ((intptr_t) res[i].udata)) continue; /* remove read handle */ @@ -363,7 +363,7 @@ sched_hook_fetch(void *root, void *arg __unused) } break; case EVFILT_WRITE: - TAILQ_FOREACH(task, &r->root_write, task_node) { + TAILQ_FOREACH_SAFE(task, &r->root_write, task_node, tmp) { if (TASK_FD(task) != ((intptr_t) res[i].udata)) continue; /* remove write handle */ @@ -420,7 +420,7 @@ sched_hook_fetch(void *root, void *arg __unused) /* timer update & put in ready queue */ clock_gettime(CLOCK_MONOTONIC, &now); - TAILQ_FOREACH(task, &r->root_timer, task_node) + TAILQ_FOREACH_SAFE(task, &r->root_timer, task_node, tmp) if (sched_timespeccmp(&now, &TASK_TS(task), -) >= 0) { #ifdef HAVE_LIBPTHREAD pthread_mutex_lock(&r->root_mtx[taskTIMER]);