|
version 1.28.2.3, 2015/07/02 22:43:30
|
version 1.31.2.4, 2017/08/31 15:26:15
|
|
Line 12 terms:
|
Line 12 terms:
|
| All of the documentation and software included in the ELWIX and AITNET |
All of the documentation and software included in the ELWIX and AITNET |
| Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
| |
|
| Copyright 2004 - 2015 | Copyright 2004 - 2017 |
| by Michael Pounov <misho@elwix.org>. All rights reserved. |
by Michael Pounov <misho@elwix.org>. All rights reserved. |
| |
|
| Redistribution and use in source and binary forms, with or without |
Redistribution and use in source and binary forms, with or without |
|
Line 245 sched_hook_cancel(void *task, void *arg __unused)
|
Line 245 sched_hook_cancel(void *task, void *arg __unused)
|
| #endif |
#endif |
| #elif SUP_ENABLE == EP_SUPPORT |
#elif SUP_ENABLE == EP_SUPPORT |
| ee.data.fd = TASK_FD(t); |
ee.data.fd = TASK_FD(t); |
| |
ee.events ^= ee.events; |
| if (FD_ISSET(TASK_FD(t), &r->root_fds[1])) |
if (FD_ISSET(TASK_FD(t), &r->root_fds[1])) |
| ee.events = EPOLLOUT; |
ee.events = EPOLLOUT; |
| |
|
| if (flg < 2) |
if (flg < 2) |
| FD_CLR(TASK_FD(t), &r->root_fds[0]); |
FD_CLR(TASK_FD(t), &r->root_fds[0]); |
| else |
else |
| ee.events |= (EPOLLIN | EPOLLPRI | EPOLLRDHUP); | ee.events |= EPOLLIN | EPOLLPRI; |
| #else |
#else |
| if (flg < 2) { |
if (flg < 2) { |
| FD_CLR(TASK_FD(t), &r->root_fds[0]); |
FD_CLR(TASK_FD(t), &r->root_fds[0]); |
|
Line 283 sched_hook_cancel(void *task, void *arg __unused)
|
Line 284 sched_hook_cancel(void *task, void *arg __unused)
|
| #endif |
#endif |
| #elif SUP_ENABLE == EP_SUPPORT |
#elif SUP_ENABLE == EP_SUPPORT |
| ee.data.fd = TASK_FD(t); |
ee.data.fd = TASK_FD(t); |
| |
ee.events ^= ee.events; |
| if (FD_ISSET(TASK_FD(t), &r->root_fds[0])) |
if (FD_ISSET(TASK_FD(t), &r->root_fds[0])) |
| ee.events = EPOLLIN | EPOLLPRI | EPOLLRDHUP; | ee.events = EPOLLIN | EPOLLPRI; |
| |
|
| if (flg < 2) |
if (flg < 2) |
| FD_CLR(TASK_FD(t), &r->root_fds[1]); |
FD_CLR(TASK_FD(t), &r->root_fds[1]); |
|
Line 553 sched_hook_read(void *task, void *arg __unused)
|
Line 555 sched_hook_read(void *task, void *arg __unused)
|
| struct kevent chg[1]; |
struct kevent chg[1]; |
| struct timespec timeout = { 0, 0 }; |
struct timespec timeout = { 0, 0 }; |
| #elif SUP_ENABLE == EP_SUPPORT |
#elif SUP_ENABLE == EP_SUPPORT |
| struct epoll_event ee = { .events = EPOLLIN | EPOLLPRI | EPOLLRDHUP, .data.fd = 0 }; | struct epoll_event ee; |
| int flg = 0; |
int flg = 0; |
| #endif |
#endif |
| |
|
|
Line 576 sched_hook_read(void *task, void *arg __unused)
|
Line 578 sched_hook_read(void *task, void *arg __unused)
|
| return (void*) -1; |
return (void*) -1; |
| } |
} |
| #elif SUP_ENABLE == EP_SUPPORT |
#elif SUP_ENABLE == EP_SUPPORT |
| |
ee.data.fd = TASK_FD(t); |
| |
ee.events = EPOLLIN | EPOLLPRI; |
| if (FD_ISSET(TASK_FD(t), &r->root_fds[0])) |
if (FD_ISSET(TASK_FD(t), &r->root_fds[0])) |
| flg |= 1; |
flg |= 1; |
| if (FD_ISSET(TASK_FD(t), &r->root_fds[1])) { |
if (FD_ISSET(TASK_FD(t), &r->root_fds[1])) { |
|
Line 583 sched_hook_read(void *task, void *arg __unused)
|
Line 587 sched_hook_read(void *task, void *arg __unused)
|
| ee.events |= EPOLLOUT; |
ee.events |= EPOLLOUT; |
| } |
} |
| |
|
| ee.data.fd = TASK_FD(t); |
|
| if (epoll_ctl(r->root_kq, flg ? EPOLL_CTL_MOD : EPOLL_CTL_ADD, TASK_FD(t), &ee) == -1) { |
if (epoll_ctl(r->root_kq, flg ? EPOLL_CTL_MOD : EPOLL_CTL_ADD, TASK_FD(t), &ee) == -1) { |
| if (r->root_hooks.hook_exec.exception) |
if (r->root_hooks.hook_exec.exception) |
| r->root_hooks.hook_exec.exception(r, NULL); |
r->root_hooks.hook_exec.exception(r, NULL); |
|
Line 617 sched_hook_write(void *task, void *arg __unused)
|
Line 620 sched_hook_write(void *task, void *arg __unused)
|
| struct kevent chg[1]; |
struct kevent chg[1]; |
| struct timespec timeout = { 0, 0 }; |
struct timespec timeout = { 0, 0 }; |
| #elif SUP_ENABLE == EP_SUPPORT |
#elif SUP_ENABLE == EP_SUPPORT |
| struct epoll_event ee = { .events = EPOLLOUT, .data.fd = 0 }; | struct epoll_event ee; |
| int flg = 0; |
int flg = 0; |
| #endif |
#endif |
| |
|
|
Line 640 sched_hook_write(void *task, void *arg __unused)
|
Line 643 sched_hook_write(void *task, void *arg __unused)
|
| return (void*) -1; |
return (void*) -1; |
| } |
} |
| #elif SUP_ENABLE == EP_SUPPORT |
#elif SUP_ENABLE == EP_SUPPORT |
| |
ee.data.fd = TASK_FD(t); |
| |
ee.events = EPOLLOUT; |
| |
|
| if (FD_ISSET(TASK_FD(t), &r->root_fds[0])) { |
if (FD_ISSET(TASK_FD(t), &r->root_fds[0])) { |
| flg |= 1; |
flg |= 1; |
| ee.events |= EPOLLIN | EPOLLPRI | EPOLLRDHUP; | ee.events |= EPOLLIN | EPOLLPRI; |
| } |
} |
| if (FD_ISSET(TASK_FD(t), &r->root_fds[1])) |
if (FD_ISSET(TASK_FD(t), &r->root_fds[1])) |
| flg |= 2; |
flg |= 2; |
| |
|
| ee.data.fd = TASK_FD(t); |
|
| if (epoll_ctl(r->root_kq, flg ? EPOLL_CTL_MOD : EPOLL_CTL_ADD, TASK_FD(t), &ee) == -1) { |
if (epoll_ctl(r->root_kq, flg ? EPOLL_CTL_MOD : EPOLL_CTL_ADD, TASK_FD(t), &ee) == -1) { |
| if (r->root_hooks.hook_exec.exception) |
if (r->root_hooks.hook_exec.exception) |
| r->root_hooks.hook_exec.exception(r, NULL); |
r->root_hooks.hook_exec.exception(r, NULL); |
|
Line 869 fetch_hook_kevent_proceed(int en, struct kevent *res,
|
Line 874 fetch_hook_kevent_proceed(int en, struct kevent *res,
|
| struct aiocb *acb; |
struct aiocb *acb; |
| #ifdef EVFILT_LIO |
#ifdef EVFILT_LIO |
| int l; |
int l; |
| register int j; |
|
| off_t off; |
off_t off; |
| struct aiocb **acbs; |
struct aiocb **acbs; |
| struct iovec *iv; |
struct iovec *iv; |
|
Line 883 fetch_hook_kevent_proceed(int en, struct kevent *res,
|
Line 887 fetch_hook_kevent_proceed(int en, struct kevent *res,
|
| switch (res[i].filter) { |
switch (res[i].filter) { |
| case EVFILT_READ: |
case EVFILT_READ: |
| TAILQ_FOREACH_SAFE(task, &r->root_read, task_node, tmp) { |
TAILQ_FOREACH_SAFE(task, &r->root_read, task_node, tmp) { |
| if (TASK_FD(task) != ((intptr_t) res[i].udata)) | if (TASK_FD(task) == ((intptr_t) res[i].udata)) { |
| continue; | |
| else { | |
| TASK_RET(task) = res[i].data; |
TASK_RET(task) = res[i].data; |
| TASK_FLAG(task) = (u_long) res[i].fflags; |
TASK_FLAG(task) = (u_long) res[i].fflags; |
| } |
|
| /* remove read handle */ |
|
| remove_task_from(task, &r->root_read); |
|
| |
|
| if (r->root_hooks.hook_exec.exception && res[i].flags & EV_EOF) { | /* remove read handle */ |
| if (r->root_hooks.hook_exec.exception(r, (void*) EV_EOF)) { | remove_task_from(task, &r->root_read); |
| task->task_type = taskUNUSE; | |
| insert_task_to(task, &r->root_unuse); | if (r->root_hooks.hook_exec.exception && res[i].flags & EV_EOF) { |
| | if (r->root_hooks.hook_exec.exception(r, (void*) EV_EOF)) { |
| | task->task_type = taskUNUSE; |
| | insert_task_to(task, &r->root_unuse); |
| | } else { |
| | task->task_type = taskREADY; |
| | insert_task_to(task, &r->root_ready); |
| | } |
| } else { |
} else { |
| task->task_type = taskREADY; |
task->task_type = taskREADY; |
| insert_task_to(task, &r->root_ready); |
insert_task_to(task, &r->root_ready); |
| } |
} |
| } else { | break; |
| task->task_type = taskREADY; | |
| insert_task_to(task, &r->root_ready); | |
| } |
} |
| } |
} |
| break; |
break; |
| case EVFILT_WRITE: |
case EVFILT_WRITE: |
| TAILQ_FOREACH_SAFE(task, &r->root_write, task_node, tmp) { |
TAILQ_FOREACH_SAFE(task, &r->root_write, task_node, tmp) { |
| if (TASK_FD(task) != ((intptr_t) res[i].udata)) | if (TASK_FD(task) == ((intptr_t) res[i].udata)) { |
| continue; | |
| else { | |
| TASK_RET(task) = res[i].data; |
TASK_RET(task) = res[i].data; |
| TASK_FLAG(task) = (u_long) res[i].fflags; |
TASK_FLAG(task) = (u_long) res[i].fflags; |
| } |
|
| /* remove write handle */ |
|
| remove_task_from(task, &r->root_write); |
|
| |
|
| if (r->root_hooks.hook_exec.exception && res[i].flags & EV_EOF) { | /* remove write handle */ |
| if (r->root_hooks.hook_exec.exception(r, (void*) EV_EOF)) { | remove_task_from(task, &r->root_write); |
| task->task_type = taskUNUSE; | |
| insert_task_to(task, &r->root_unuse); | if (r->root_hooks.hook_exec.exception && res[i].flags & EV_EOF) { |
| | if (r->root_hooks.hook_exec.exception(r, (void*) EV_EOF)) { |
| | task->task_type = taskUNUSE; |
| | insert_task_to(task, &r->root_unuse); |
| | } else { |
| | task->task_type = taskREADY; |
| | insert_task_to(task, &r->root_ready); |
| | } |
| } else { |
} else { |
| task->task_type = taskREADY; |
task->task_type = taskREADY; |
| insert_task_to(task, &r->root_ready); |
insert_task_to(task, &r->root_ready); |
| } |
} |
| } else { | break; |
| task->task_type = taskREADY; | |
| insert_task_to(task, &r->root_ready); | |
| } |
} |
| } |
} |
| break; |
break; |
| case EVFILT_TIMER: |
case EVFILT_TIMER: |
| TAILQ_FOREACH_SAFE(task, &r->root_alarm, task_node, tmp) { |
TAILQ_FOREACH_SAFE(task, &r->root_alarm, task_node, tmp) { |
| if ((uintptr_t) TASK_DATA(task) != ((uintptr_t) res[i].udata)) | if ((uintptr_t) TASK_DATA(task) == ((uintptr_t) res[i].udata)) { |
| continue; | |
| else { | |
| TASK_RET(task) = res[i].data; |
TASK_RET(task) = res[i].data; |
| TASK_FLAG(task) = (u_long) res[i].fflags; |
TASK_FLAG(task) = (u_long) res[i].fflags; |
| |
|
| |
/* remove alarm handle */ |
| |
transit_task2ready(task, &r->root_alarm); |
| |
break; |
| } |
} |
| /* remove alarm handle */ |
|
| transit_task2ready(task, &r->root_alarm); |
|
| } |
} |
| break; |
break; |
| case EVFILT_VNODE: |
case EVFILT_VNODE: |
| TAILQ_FOREACH_SAFE(task, &r->root_node, task_node, tmp) { |
TAILQ_FOREACH_SAFE(task, &r->root_node, task_node, tmp) { |
| if (TASK_FD(task) != ((intptr_t) res[i].udata)) | if (TASK_FD(task) == ((intptr_t) res[i].udata)) { |
| continue; | |
| else { | |
| TASK_RET(task) = res[i].data; |
TASK_RET(task) = res[i].data; |
| TASK_FLAG(task) = (u_long) res[i].fflags; |
TASK_FLAG(task) = (u_long) res[i].fflags; |
| |
|
| |
/* remove node handle */ |
| |
transit_task2ready(task, &r->root_node); |
| |
break; |
| } |
} |
| /* remove node handle */ |
|
| transit_task2ready(task, &r->root_node); |
|
| } |
} |
| break; |
break; |
| case EVFILT_PROC: |
case EVFILT_PROC: |
| TAILQ_FOREACH_SAFE(task, &r->root_proc, task_node, tmp) { |
TAILQ_FOREACH_SAFE(task, &r->root_proc, task_node, tmp) { |
| if (TASK_VAL(task) != ((uintptr_t) res[i].udata)) | if (TASK_VAL(task) == ((uintptr_t) res[i].udata)) { |
| continue; | |
| else { | |
| TASK_RET(task) = res[i].data; |
TASK_RET(task) = res[i].data; |
| TASK_FLAG(task) = (u_long) res[i].fflags; |
TASK_FLAG(task) = (u_long) res[i].fflags; |
| |
|
| |
/* remove proc handle */ |
| |
transit_task2ready(task, &r->root_proc); |
| |
break; |
| } |
} |
| /* remove proc handle */ |
|
| transit_task2ready(task, &r->root_proc); |
|
| } |
} |
| break; |
break; |
| case EVFILT_SIGNAL: |
case EVFILT_SIGNAL: |
| TAILQ_FOREACH_SAFE(task, &r->root_signal, task_node, tmp) { |
TAILQ_FOREACH_SAFE(task, &r->root_signal, task_node, tmp) { |
| if (TASK_VAL(task) != ((uintptr_t) res[i].udata)) | if (TASK_VAL(task) == ((uintptr_t) res[i].udata)) { |
| continue; | |
| else { | |
| TASK_RET(task) = res[i].data; |
TASK_RET(task) = res[i].data; |
| TASK_FLAG(task) = (u_long) res[i].fflags; |
TASK_FLAG(task) = (u_long) res[i].fflags; |
| |
|
| |
/* remove signal handle */ |
| |
transit_task2ready(task, &r->root_signal); |
| |
break; |
| } |
} |
| /* remove signal handle */ |
|
| transit_task2ready(task, &r->root_signal); |
|
| } |
} |
| break; |
break; |
| #ifdef AIO_SUPPORT |
#ifdef AIO_SUPPORT |
| case EVFILT_AIO: |
case EVFILT_AIO: |
| TAILQ_FOREACH_SAFE(task, &r->root_aio, task_node, tmp) { |
TAILQ_FOREACH_SAFE(task, &r->root_aio, task_node, tmp) { |
| acb = (struct aiocb*) TASK_VAL(task); |
acb = (struct aiocb*) TASK_VAL(task); |
| if (acb != ((struct aiocb*) res[i].udata)) | if (acb == ((struct aiocb*) res[i].udata)) { |
| continue; | |
| else { | |
| TASK_RET(task) = res[i].data; |
TASK_RET(task) = res[i].data; |
| TASK_FLAG(task) = (u_long) res[i].fflags; |
TASK_FLAG(task) = (u_long) res[i].fflags; |
| } | |
| /* remove user handle */ | /* remove user handle */ |
| transit_task2ready(task, &r->root_aio); | transit_task2ready(task, &r->root_aio); |
| |
|
| fd = acb->aio_fildes; | fd = acb->aio_fildes; |
| if ((len = aio_return(acb)) != -1) { | if ((len = aio_return(acb)) != -1) { |
| if (lseek(fd, acb->aio_offset + len, SEEK_CUR) == -1) | if (lseek(fd, acb->aio_offset + len, SEEK_CUR) == -1) |
| | LOGERR; |
| | } else |
| LOGERR; |
LOGERR; |
| } else | free(acb); |
| LOGERR; | TASK_DATLEN(task) = (u_long) len; |
| free(acb); | TASK_FD(task) = fd; |
| TASK_DATLEN(task) = (u_long) len; | break; |
| TASK_FD(task) = fd; | } |
| } |
} |
| break; |
break; |
| #ifdef EVFILT_LIO |
#ifdef EVFILT_LIO |
| case EVFILT_LIO: |
case EVFILT_LIO: |
| TAILQ_FOREACH_SAFE(task, &r->root_lio, task_node, tmp) { |
TAILQ_FOREACH_SAFE(task, &r->root_lio, task_node, tmp) { |
| acbs = (struct aiocb**) TASK_VAL(task); |
acbs = (struct aiocb**) TASK_VAL(task); |
| if (acbs != ((struct aiocb**) res[i].udata)) | if (acbs == ((struct aiocb**) res[i].udata)) { |
| continue; | |
| else { | |
| TASK_RET(task) = res[i].data; |
TASK_RET(task) = res[i].data; |
| TASK_FLAG(task) = (u_long) res[i].fflags; |
TASK_FLAG(task) = (u_long) res[i].fflags; |
| } |
|
| /* remove user handle */ |
|
| transit_task2ready(task, &r->root_lio); |
|
| |
|
| iv = (struct iovec*) TASK_DATA(task); | /* remove user handle */ |
| fd = acbs[0]->aio_fildes; | transit_task2ready(task, &r->root_lio); |
| off = acbs[0]->aio_offset; | |
| for (j = len = 0; i < TASK_DATLEN(task); len += l, i++) { | |
| if ((iv[i].iov_len = aio_return(acbs[i])) == -1) | |
| l = 0; | |
| else | |
| l = iv[i].iov_len; | |
| free(acbs[i]); | |
| } | |
| free(acbs); | |
| TASK_DATLEN(task) = (u_long) len; | |
| TASK_FD(task) = fd; | |
| |
|
| if (lseek(fd, off + len, SEEK_CUR) == -1) | iv = (struct iovec*) TASK_DATA(task); |
| LOGERR; | fd = acbs[0]->aio_fildes; |
| | off = acbs[0]->aio_offset; |
| | for (len = 0; i < TASK_DATLEN(task); len += l, i++) { |
| | if ((iv[i].iov_len = aio_return(acbs[i])) == -1) |
| | l = 0; |
| | else |
| | l = iv[i].iov_len; |
| | free(acbs[i]); |
| | } |
| | free(acbs); |
| | TASK_DATLEN(task) = (u_long) len; |
| | TASK_FD(task) = fd; |
| | |
| | if (lseek(fd, off + len, SEEK_CUR) == -1) |
| | LOGERR; |
| | break; |
| | } |
| } |
} |
| break; |
break; |
| #endif /* EVFILT_LIO */ |
#endif /* EVFILT_LIO */ |
|
Line 1039 fetch_hook_kevent_proceed(int en, struct kevent *res,
|
Line 1043 fetch_hook_kevent_proceed(int en, struct kevent *res,
|
| #ifdef EVFILT_USER |
#ifdef EVFILT_USER |
| case EVFILT_USER: |
case EVFILT_USER: |
| TAILQ_FOREACH_SAFE(task, &r->root_user, task_node, tmp) { |
TAILQ_FOREACH_SAFE(task, &r->root_user, task_node, tmp) { |
| if (TASK_VAL(task) != ((uintptr_t) res[i].udata)) | if (TASK_VAL(task) == ((uintptr_t) res[i].udata)) { |
| continue; | |
| else { | |
| TASK_RET(task) = res[i].data; |
TASK_RET(task) = res[i].data; |
| TASK_FLAG(task) = (u_long) res[i].fflags; |
TASK_FLAG(task) = (u_long) res[i].fflags; |
| |
|
| |
/* remove user handle */ |
| |
transit_task2ready(task, &r->root_user); |
| |
break; |
| } |
} |
| /* remove user handle */ |
|
| transit_task2ready(task, &r->root_user); |
|
| } |
} |
| break; |
break; |
| #endif /* EVFILT_USER */ |
#endif /* EVFILT_USER */ |
|
Line 1068 fetch_hook_epoll_proceed(int en, struct epoll_event *r
|
Line 1072 fetch_hook_epoll_proceed(int en, struct epoll_event *r
|
| { |
{ |
| register int i, flg; |
register int i, flg; |
| int ops = EPOLL_CTL_DEL; |
int ops = EPOLL_CTL_DEL; |
| sched_task_t *task, *tmp; | sched_task_t *t, *tmp, *task; |
| struct epoll_event evt[1]; |
struct epoll_event evt[1]; |
| |
|
| for (i = 0; i < en; i++) { |
for (i = 0; i < en; i++) { |
| memcpy(evt, &res[i], sizeof evt); |
memcpy(evt, &res[i], sizeof evt); |
| |
|
| if (evt->events & (EPOLLIN | EPOLLPRI | EPOLLET)) { | if (evt->events & (EPOLLIN | EPOLLPRI)) { |
| flg = 0; |
flg = 0; |
| TAILQ_FOREACH_SAFE(task, &r->root_read, task_node, tmp) { | task = NULL; |
| if (TASK_FD(task) != evt->data.fd) | TAILQ_FOREACH_SAFE(t, &r->root_read, task_node, tmp) { |
| continue; | if (TASK_FD(t) == evt->data.fd) { |
| else { | if (!flg) |
| | task = t; |
| flg++; |
flg++; |
| FD_CLR(TASK_FD(task), &r->root_fds[0]); |
|
| TASK_FLAG(task) = ioctl(TASK_FD(task), FIONREAD, &TASK_RET(task)); |
|
| |
|
| evt->events &= ~(EPOLLIN | EPOLLPRI | EPOLLET | EPOLLRDHUP); |
|
| if (FD_ISSET(TASK_FD(task), &r->root_fds[1])) { |
|
| ops = EPOLL_CTL_MOD; |
|
| evt->events |= EPOLLOUT; |
|
| } |
|
| } |
} |
| |
} |
| |
|
| |
if (flg && task) { |
| |
TASK_FLAG(task) = ioctl(TASK_FD(task), FIONREAD, &TASK_RET(task)); |
| /* remove read handle */ |
/* remove read handle */ |
| remove_task_from(task, &r->root_read); |
remove_task_from(task, &r->root_read); |
| |
|
|
Line 1106 fetch_hook_epoll_proceed(int en, struct epoll_event *r
|
Line 1107 fetch_hook_epoll_proceed(int en, struct epoll_event *r
|
| task->task_type = taskREADY; |
task->task_type = taskREADY; |
| insert_task_to(task, &r->root_ready); |
insert_task_to(task, &r->root_ready); |
| } |
} |
| } |
|
| if (flg > 1) |
|
| ops = EPOLL_CTL_MOD; |
|
| } |
|
| |
|
| if (evt->events & EPOLLOUT) { | evt->events ^= evt->events; |
| | if (FD_ISSET(evt->data.fd, &r->root_fds[1])) { |
| | ops = EPOLL_CTL_MOD; |
| | evt->events |= EPOLLOUT; |
| | } |
| | if (flg > 1) { |
| | ops = EPOLL_CTL_MOD; |
| | evt->events |= EPOLLIN | EPOLLPRI; |
| | } else |
| | FD_CLR(evt->data.fd, &r->root_fds[0]); |
| | } |
| | } else if (evt->events & EPOLLOUT) { |
| flg = 0; |
flg = 0; |
| TAILQ_FOREACH_SAFE(task, &r->root_write, task_node, tmp) { | task = NULL; |
| if (TASK_FD(task) != evt->data.fd) | TAILQ_FOREACH_SAFE(t, &r->root_write, task_node, tmp) { |
| continue; | if (TASK_FD(t) == evt->data.fd) { |
| else { | if (!flg) |
| | task = t; |
| flg++; |
flg++; |
| FD_CLR(TASK_FD(task), &r->root_fds[1]); |
|
| TASK_FLAG(task) = ioctl(TASK_FD(task), |
|
| FIONWRITE, &TASK_RET(task)); |
|
| |
|
| evt->events &= ~EPOLLOUT; |
|
| if (FD_ISSET(TASK_FD(task), &r->root_fds[0])) { |
|
| ops = EPOLL_CTL_MOD; |
|
| evt->events |= EPOLLIN | EPOLLPRI | EPOLLRDHUP; |
|
| } |
|
| } |
} |
| |
} |
| |
|
| |
if (flg && task) { |
| |
TASK_FLAG(task) = ioctl(TASK_FD(task), FIONWRITE, &TASK_RET(task)); |
| /* remove write handle */ |
/* remove write handle */ |
| remove_task_from(task, &r->root_write); |
remove_task_from(task, &r->root_write); |
| |
|
|
Line 1144 fetch_hook_epoll_proceed(int en, struct epoll_event *r
|
Line 1148 fetch_hook_epoll_proceed(int en, struct epoll_event *r
|
| task->task_type = taskREADY; |
task->task_type = taskREADY; |
| insert_task_to(task, &r->root_ready); |
insert_task_to(task, &r->root_ready); |
| } |
} |
| |
|
| |
evt->events ^= evt->events; |
| |
if (FD_ISSET(evt->data.fd, &r->root_fds[0])) { |
| |
ops = EPOLL_CTL_MOD; |
| |
evt->events |= EPOLLIN | EPOLLPRI; |
| |
} |
| |
if (flg > 1) { |
| |
ops = EPOLL_CTL_MOD; |
| |
evt->events |= EPOLLOUT; |
| |
} else |
| |
FD_CLR(evt->data.fd, &r->root_fds[1]); |
| } |
} |
| if (flg > 1) |
|
| ops = EPOLL_CTL_MOD; |
|
| } |
} |
| |
|
| if (epoll_ctl(r->root_kq, ops, evt->data.fd, evt) == -1) { |
if (epoll_ctl(r->root_kq, ops, evt->data.fd, evt) == -1) { |
|
Line 1164 static inline void
|
Line 1177 static inline void
|
| fetch_hook_select_proceed(int en, fd_set rfd, fd_set wfd, fd_set xfd, sched_root_task_t *r) |
fetch_hook_select_proceed(int en, fd_set rfd, fd_set wfd, fd_set xfd, sched_root_task_t *r) |
| { |
{ |
| register int i, flg; |
register int i, flg; |
| sched_task_t *task, *tmp; | sched_task_t *t, *tmp, *task = NULL; |
| |
|
| /* skip select check if return value from select is zero */ |
/* skip select check if return value from select is zero */ |
| if (!en) |
if (!en) |
|
Line 1173 fetch_hook_select_proceed(int en, fd_set rfd, fd_set w
|
Line 1186 fetch_hook_select_proceed(int en, fd_set rfd, fd_set w
|
| for (i = 0; i < r->root_kq; i++) { |
for (i = 0; i < r->root_kq; i++) { |
| if (FD_ISSET(i, &rfd) || FD_ISSET(i, &xfd)) { |
if (FD_ISSET(i, &rfd) || FD_ISSET(i, &xfd)) { |
| flg = 0; |
flg = 0; |
| TAILQ_FOREACH_SAFE(task, &r->root_read, task_node, tmp) { | TAILQ_FOREACH_SAFE(t, &r->root_read, task_node, tmp) { |
| if (TASK_FD(task) != i) | if (TASK_FD(t) == i) { |
| continue; | if (!flg) |
| else { | task = t; |
| flg++; |
flg++; |
| TASK_FLAG(task) = ioctl(TASK_FD(task), |
|
| FIONREAD, &TASK_RET(task)); |
|
| } |
} |
| |
} |
| |
|
| |
if (flg && task) { |
| |
TASK_FLAG(task) = ioctl(TASK_FD(task), FIONREAD, &TASK_RET(task)); |
| |
|
| /* remove read handle */ |
/* remove read handle */ |
| remove_task_from(task, &r->root_read); |
remove_task_from(task, &r->root_read); |
| |
|
|
Line 1196 fetch_hook_select_proceed(int en, fd_set rfd, fd_set w
|
Line 1212 fetch_hook_select_proceed(int en, fd_set rfd, fd_set w
|
| task->task_type = taskREADY; |
task->task_type = taskREADY; |
| insert_task_to(task, &r->root_ready); |
insert_task_to(task, &r->root_ready); |
| } |
} |
| } |
|
| /* remove resouce */ |
|
| if (flg) |
|
| FD_CLR(i, &r->root_fds[0]); |
|
| } |
|
| |
|
| if (FD_ISSET(i, &wfd)) { | /* remove resouce */ |
| | if (flg == 1) |
| | FD_CLR(i, &r->root_fds[0]); |
| | } |
| | } else if (FD_ISSET(i, &wfd)) { |
| flg = 0; |
flg = 0; |
| TAILQ_FOREACH_SAFE(task, &r->root_write, task_node, tmp) { | TAILQ_FOREACH_SAFE(t, &r->root_write, task_node, tmp) { |
| if (TASK_FD(task) != i) | if (TASK_FD(t) == i) { |
| continue; | if (!flg) |
| else { | task = t; |
| flg++; |
flg++; |
| TASK_FLAG(task) = ioctl(TASK_FD(task), |
|
| FIONWRITE, &TASK_RET(task)); |
|
| } |
} |
| |
} |
| |
|
| |
if (flg && task) { |
| |
TASK_FLAG(task) = ioctl(TASK_FD(task), FIONWRITE, &TASK_RET(task)); |
| |
|
| /* remove write handle */ |
/* remove write handle */ |
| remove_task_from(task, &r->root_write); |
remove_task_from(task, &r->root_write); |
| |
|
|
Line 1227 fetch_hook_select_proceed(int en, fd_set rfd, fd_set w
|
Line 1245 fetch_hook_select_proceed(int en, fd_set rfd, fd_set w
|
| task->task_type = taskREADY; |
task->task_type = taskREADY; |
| insert_task_to(task, &r->root_ready); |
insert_task_to(task, &r->root_ready); |
| } |
} |
| |
|
| |
/* remove resouce */ |
| |
if (flg == 1) |
| |
FD_CLR(i, &r->root_fds[1]); |
| } |
} |
| /* remove resouce */ |
|
| if (flg) |
|
| FD_CLR(i, &r->root_fds[1]); |
|
| } |
} |
| } |
} |
| |
|
|
Line 1454 sched_hook_condition(void *root, void *arg)
|
Line 1473 sched_hook_condition(void *root, void *arg)
|
| * @arg = unused |
* @arg = unused |
| * return: <0 errors and 0 ok |
* return: <0 errors and 0 ok |
| */ |
*/ |
| #if defined(HAVE_LIBRT) && defined(HAVE_TIMER_CREATE) && \ |
|
| defined(HAVE_TIMER_SETTIME) && defined(HAVE_TIMER_DELETE) |
|
| void * |
void * |
| sched_hook_rtc(void *task, void *arg __unused) |
sched_hook_rtc(void *task, void *arg __unused) |
| { |
{ |
| |
#if defined(HAVE_LIBRT) && defined(HAVE_TIMER_CREATE) && \ |
| |
defined(HAVE_TIMER_SETTIME) && defined(HAVE_TIMER_DELETE) |
| sched_task_t *sigt = NULL, *t = task; |
sched_task_t *sigt = NULL, *t = task; |
| struct itimerspec its; |
struct itimerspec its; |
| struct sigevent evt; |
struct sigevent evt; |
|
Line 1524 sched_hook_rtc(void *task, void *arg __unused)
|
Line 1543 sched_hook_rtc(void *task, void *arg __unused)
|
| timer_delete(tmr); |
timer_delete(tmr); |
| return (void*) -1; |
return (void*) -1; |
| } |
} |
| #endif /* HAVE_TIMER_CREATE */ |
| return NULL; |
return NULL; |
| } |
} |
| #endif /* HAVE_TIMER_CREATE */ |
|