version 1.29, 2015/07/02 22:45:00
|
version 1.31.2.1, 2017/08/31 12:18:38
|
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 - 2016 |
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 = { .events = EPOLLIN | EPOLLPRI, .data.fd = 0 }; |
int flg = 0; |
int flg = 0; |
#endif |
#endif |
|
|
Line 642 sched_hook_write(void *task, void *arg __unused)
|
Line 644 sched_hook_write(void *task, void *arg __unused)
|
#elif SUP_ENABLE == EP_SUPPORT |
#elif SUP_ENABLE == EP_SUPPORT |
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; |
Line 869 fetch_hook_kevent_proceed(int en, struct kevent *res,
|
Line 871 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 1019 fetch_hook_kevent_proceed(int en, struct kevent *res,
|
Line 1020 fetch_hook_kevent_proceed(int en, struct kevent *res,
|
iv = (struct iovec*) TASK_DATA(task); |
iv = (struct iovec*) TASK_DATA(task); |
fd = acbs[0]->aio_fildes; |
fd = acbs[0]->aio_fildes; |
off = acbs[0]->aio_offset; |
off = acbs[0]->aio_offset; |
for (j = len = 0; i < TASK_DATLEN(task); len += l, i++) { | for (len = 0; i < TASK_DATLEN(task); len += l, i++) { |
if ((iv[i].iov_len = aio_return(acbs[i])) == -1) |
if ((iv[i].iov_len = aio_return(acbs[i])) == -1) |
l = 0; |
l = 0; |
else |
else |
Line 1066 fetch_hook_kevent_proceed(int en, struct kevent *res,
|
Line 1067 fetch_hook_kevent_proceed(int en, struct kevent *res,
|
static inline void |
static inline void |
fetch_hook_epoll_proceed(int en, struct epoll_event *res, sched_root_task_t *r) |
fetch_hook_epoll_proceed(int en, struct epoll_event *res, sched_root_task_t *r) |
{ |
{ |
register int i, flg; | register int i, flg, oevt; |
int ops = EPOLL_CTL_DEL; |
int ops = EPOLL_CTL_DEL; |
sched_task_t *task, *tmp; |
sched_task_t *task, *tmp; |
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); |
|
oevt = evt->events & EPOLLOUT; |
|
|
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) { |
TAILQ_FOREACH_SAFE(task, &r->root_read, task_node, tmp) { |
if (TASK_FD(task) != evt->data.fd) |
if (TASK_FD(task) != evt->data.fd) |
continue; |
continue; |
else { |
else { |
flg++; |
flg++; |
FD_CLR(TASK_FD(task), &r->root_fds[0]); |
|
TASK_FLAG(task) = ioctl(TASK_FD(task), FIONREAD, &TASK_RET(task)); |
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; |
|
} |
|
} |
} |
/* remove read handle */ |
/* remove read handle */ |
remove_task_from(task, &r->root_read); |
remove_task_from(task, &r->root_read); |
Line 1107 fetch_hook_epoll_proceed(int en, struct epoll_event *r
|
Line 1102 fetch_hook_epoll_proceed(int en, struct epoll_event *r
|
insert_task_to(task, &r->root_ready); |
insert_task_to(task, &r->root_ready); |
} |
} |
} |
} |
if (flg > 1) | |
ops = EPOLL_CTL_MOD; | if (flg) { |
| 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]); |
| } |
} |
} |
|
|
if (evt->events & EPOLLOUT) { | if (oevt) { |
flg = 0; |
flg = 0; |
TAILQ_FOREACH_SAFE(task, &r->root_write, task_node, tmp) { |
TAILQ_FOREACH_SAFE(task, &r->root_write, task_node, tmp) { |
if (TASK_FD(task) != evt->data.fd) |
if (TASK_FD(task) != evt->data.fd) |
continue; |
continue; |
else { |
else { |
flg++; |
flg++; |
FD_CLR(TASK_FD(task), &r->root_fds[1]); |
|
TASK_FLAG(task) = ioctl(TASK_FD(task), |
TASK_FLAG(task) = ioctl(TASK_FD(task), |
FIONWRITE, &TASK_RET(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; |
|
} |
|
} |
} |
/* remove write handle */ |
/* remove write handle */ |
remove_task_from(task, &r->root_write); |
remove_task_from(task, &r->root_write); |
Line 1145 fetch_hook_epoll_proceed(int en, struct epoll_event *r
|
Line 1144 fetch_hook_epoll_proceed(int en, struct epoll_event *r
|
insert_task_to(task, &r->root_ready); |
insert_task_to(task, &r->root_ready); |
} |
} |
} |
} |
if (flg > 1) | |
ops = EPOLL_CTL_MOD; | if (flg) { |
| 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 (epoll_ctl(r->root_kq, ops, evt->data.fd, evt) == -1) { |
if (epoll_ctl(r->root_kq, ops, evt->data.fd, evt) == -1) { |
Line 1454 sched_hook_condition(void *root, void *arg)
|
Line 1464 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 1534 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 */ |
|