version 1.2.2.1, 2011/10/04 13:29:00
|
version 1.2.2.4, 2011/10/04 23:03:32
|
Line 184 sched_hook_read(void *task, void *arg __unused)
|
Line 184 sched_hook_read(void *task, void *arg __unused)
|
if (kevent(t->task_root->root_kq, chg, 1, NULL, 0, &timeout) == -1) { |
if (kevent(t->task_root->root_kq, chg, 1, NULL, 0, &timeout) == -1) { |
if (t->task_root->root_hooks.hook_exec.exception) |
if (t->task_root->root_hooks.hook_exec.exception) |
t->task_root->root_hooks.hook_exec.exception(t->task_root, NULL); |
t->task_root->root_hooks.hook_exec.exception(t->task_root, NULL); |
|
else |
|
LOGERR; |
return (void*) -1; |
return (void*) -1; |
} |
} |
|
|
Line 222 sched_hook_write(void *task, void *arg __unused)
|
Line 224 sched_hook_write(void *task, void *arg __unused)
|
if (kevent(t->task_root->root_kq, chg, 1, NULL, 0, &timeout) == -1) { |
if (kevent(t->task_root->root_kq, chg, 1, NULL, 0, &timeout) == -1) { |
if (t->task_root->root_hooks.hook_exec.exception) |
if (t->task_root->root_hooks.hook_exec.exception) |
t->task_root->root_hooks.hook_exec.exception(t->task_root, NULL); |
t->task_root->root_hooks.hook_exec.exception(t->task_root, NULL); |
|
else |
|
LOGERR; |
return (void*) -1; |
return (void*) -1; |
} |
} |
|
|
Line 310 retry:
|
Line 314 retry:
|
} else /* wait INFTIM */ |
} else /* wait INFTIM */ |
timeout = NULL; |
timeout = NULL; |
if ((en = kevent(r->root_kq, NULL, 0, res, KQ_EVENTS, timeout)) == -1) { |
if ((en = kevent(r->root_kq, NULL, 0, res, KQ_EVENTS, timeout)) == -1) { |
if (r->root_hooks.hook_exec.exception) | if (r->root_hooks.hook_exec.exception) { |
if (r->root_hooks.hook_exec.exception(r, NULL)) |
if (r->root_hooks.hook_exec.exception(r, NULL)) |
return NULL; /* exit from scheduler */ | return NULL; |
| } else |
| LOGERR; |
#ifdef NDEBUG |
#ifdef NDEBUG |
/* kevent no exit by error, if non-debug version */ |
/* kevent no exit by error, if non-debug version */ |
goto retry; |
goto retry; |
Line 331 retry:
|
Line 337 retry:
|
switch (res[i].filter) { |
switch (res[i].filter) { |
case EVFILT_READ: |
case EVFILT_READ: |
TAILQ_FOREACH(task, &r->root_read, task_node) { |
TAILQ_FOREACH(task, &r->root_read, task_node) { |
if (TASK_FD(task) != ((int) res[i].udata)) | if (TASK_FD(task) != ((intptr_t) res[i].udata)) |
continue; |
continue; |
/* remove read handle */ |
/* remove read handle */ |
io = ROOT_DATA(task->task_root); |
io = ROOT_DATA(task->task_root); |
Line 355 retry:
|
Line 361 retry:
|
break; |
break; |
case EVFILT_WRITE: |
case EVFILT_WRITE: |
TAILQ_FOREACH(task, &r->root_write, task_node) { |
TAILQ_FOREACH(task, &r->root_write, task_node) { |
if (TASK_FD(task) != ((int) res[i].udata)) | if (TASK_FD(task) != ((intptr_t) res[i].udata)) |
continue; |
continue; |
/* remove write handle */ |
/* remove write handle */ |
io = ROOT_DATA(task->task_root); |
io = ROOT_DATA(task->task_root); |
Line 378 retry:
|
Line 384 retry:
|
} |
} |
break; |
break; |
} |
} |
if (kevent(r->root_kq, evt, 1, NULL, 0, &nw) == -1) | if (kevent(r->root_kq, evt, 1, NULL, 0, &nw) == -1) { |
if (r->root_hooks.hook_exec.exception) | if (r->root_hooks.hook_exec.exception) { |
if (r->root_hooks.hook_exec.exception(r, NULL)) |
if (r->root_hooks.hook_exec.exception(r, NULL)) |
return NULL; /* exit from scheduler */ | return NULL; |
| } else |
| LOGERR; |
| } |
} |
} |
|
|
/* timer update & put in ready queue */ |
/* timer update & put in ready queue */ |
Line 422 retry:
|
Line 431 retry:
|
/* |
/* |
* sched_hook_exception() - Default EXCEPTION hook |
* sched_hook_exception() - Default EXCEPTION hook |
* @root = root task |
* @root = root task |
* @arg = may be EV_EOF | * @arg = custom handling: if arg == EV_EOF or other value; default: arg == NULL log errno |
* return: <0 errors and 0 ok |
* return: <0 errors and 0 ok |
*/ |
*/ |
void * |
void * |
Line 433 sched_hook_exception(void *root, void *arg)
|
Line 442 sched_hook_exception(void *root, void *arg)
|
if (!r || !ROOT_DATA(r) || !ROOT_DATLEN(r)) |
if (!r || !ROOT_DATA(r) || !ROOT_DATLEN(r)) |
return NULL; |
return NULL; |
|
|
|
/* custom exception handling ... */ |
if (arg) { |
if (arg) { |
if (arg == (void*) EV_EOF) |
if (arg == (void*) EV_EOF) |
return NULL; |
return NULL; |
return (void*) -1; /* raise error */ | return (void*) -1; /* raise scheduler error!!! */ |
} else | } |
LOGERR; | |
|
|
if (errno == EINTR) | /* if error hook exists */ |
return (void*) -1; /* raise error */ | if (r->root_hooks.hook_root.error) |
| return (r->root_hooks.hook_root.error(root, (void*) ((intptr_t) errno))); |
|
|
|
/* default case! */ |
|
LOGERR; |
return NULL; |
return NULL; |
} |
} |