|
|
| version 1.36, 2022/10/17 22:45:06 | version 1.36.2.1, 2022/10/19 01:44:25 |
|---|---|
| Line 204 sched_hook_cancel(void *task, void *arg __unused) | Line 204 sched_hook_cancel(void *task, void *arg __unused) |
| { | { |
| sched_task_t *t = task, *tmp, *tt; | sched_task_t *t = task, *tmp, *tt; |
| sched_root_task_t *r = NULL; | sched_root_task_t *r = NULL; |
| int flg; | int flg = 0; |
| #if SUP_ENABLE == KQ_SUPPORT | #if SUP_ENABLE == KQ_SUPPORT |
| struct kevent chg[1]; | struct kevent chg[1]; |
| struct timespec timeout = { 0, 0 }; | struct timespec timeout = { 0, 0 }; |
| Line 229 sched_hook_cancel(void *task, void *arg __unused) | Line 229 sched_hook_cancel(void *task, void *arg __unused) |
| switch (TASK_TYPE(t)) { | switch (TASK_TYPE(t)) { |
| case taskREAD: | case taskREAD: |
| /* check for multi subscribers */ | /* check for multi subscribers */ |
| flg = 0; | |
| TAILQ_FOREACH_SAFE(tt, &r->root_read, task_node, tmp) | TAILQ_FOREACH_SAFE(tt, &r->root_read, task_node, tmp) |
| if (TASK_FD(tt) != TASK_FD(t)) | if (TASK_FD(tt) == TASK_FD(t)) |
| continue; | |
| else | |
| flg++; | flg++; |
| #if SUP_ENABLE == KQ_SUPPORT | #if SUP_ENABLE == KQ_SUPPORT |
| #ifdef __NetBSD__ | #ifdef __NetBSD__ |
| Line 258 sched_hook_cancel(void *task, void *arg __unused) | Line 255 sched_hook_cancel(void *task, void *arg __unused) |
| FD_CLR(TASK_FD(t), &r->root_fds[0]); | FD_CLR(TASK_FD(t), &r->root_fds[0]); |
| /* optimize select */ | /* optimize select */ |
| for (i = r->root_kq - 1; i > 2; i--) | for (i = r->root_kq - 1; i >= 0; i--) |
| if (FD_ISSET(i, &r->root_fds[0]) || FD_ISSET(i, &r->root_fds[1])) | if (FD_ISSET(i, &r->root_fds[0]) || FD_ISSET(i, &r->root_fds[1])) |
| break; | break; |
| if (i > 2) | r->root_kq = i + 1; |
| r->root_kq = i + 1; | |
| } | } |
| #endif | #endif |
| break; | break; |
| case taskWRITE: | case taskWRITE: |
| /* check for multi subscribers */ | /* check for multi subscribers */ |
| flg = 0; | |
| TAILQ_FOREACH_SAFE(tt, &r->root_write, task_node, tmp) | TAILQ_FOREACH_SAFE(tt, &r->root_write, task_node, tmp) |
| if (TASK_FD(tt) != TASK_FD(t)) | if (TASK_FD(tt) == TASK_FD(t)) |
| continue; | |
| else | |
| flg++; | flg++; |
| #if SUP_ENABLE == KQ_SUPPORT | #if SUP_ENABLE == KQ_SUPPORT |
| #ifdef __NetBSD__ | #ifdef __NetBSD__ |
| Line 297 sched_hook_cancel(void *task, void *arg __unused) | Line 290 sched_hook_cancel(void *task, void *arg __unused) |
| FD_CLR(TASK_FD(t), &r->root_fds[1]); | FD_CLR(TASK_FD(t), &r->root_fds[1]); |
| /* optimize select */ | /* optimize select */ |
| for (i = r->root_kq - 1; i > 2; i--) | for (i = r->root_kq - 1; i >= 0; i--) |
| if (FD_ISSET(i, &r->root_fds[0]) || FD_ISSET(i, &r->root_fds[1])) | if (FD_ISSET(i, &r->root_fds[0]) || FD_ISSET(i, &r->root_fds[1])) |
| break; | break; |
| if (i > 2) | r->root_kq = i + 1; |
| r->root_kq = i + 1; | |
| } | } |
| #endif | #endif |
| break; | break; |
| case taskALARM: | case taskALARM: |
| #if SUP_ENABLE == KQ_SUPPORT | #if SUP_ENABLE == KQ_SUPPORT |
| /* check for multi subscribers */ | /* check for multi subscribers */ |
| flg = 0; | |
| TAILQ_FOREACH_SAFE(tt, &r->root_alarm, task_node, tmp) | TAILQ_FOREACH_SAFE(tt, &r->root_alarm, task_node, tmp) |
| if (TASK_DATA(tt) != TASK_DATA(t)) | if (TASK_DATA(tt) == TASK_DATA(t)) |
| continue; | |
| else | |
| flg++; | flg++; |
| #ifdef __NetBSD__ | #ifdef __NetBSD__ |
| EV_SET(&chg[0], (uintptr_t) TASK_DATA(t), EVFILT_TIMER, flg < 2 ? EV_DELETE : 0, | EV_SET(&chg[0], (uintptr_t) TASK_DATA(t), EVFILT_TIMER, flg < 2 ? EV_DELETE : 0, |
| Line 326 sched_hook_cancel(void *task, void *arg __unused) | Line 315 sched_hook_cancel(void *task, void *arg __unused) |
| case taskNODE: | case taskNODE: |
| #if SUP_ENABLE == KQ_SUPPORT | #if SUP_ENABLE == KQ_SUPPORT |
| /* check for multi subscribers */ | /* check for multi subscribers */ |
| flg = 0; | |
| TAILQ_FOREACH_SAFE(tt, &r->root_node, task_node, tmp) | TAILQ_FOREACH_SAFE(tt, &r->root_node, task_node, tmp) |
| if (TASK_FD(tt) != TASK_FD(t)) | if (TASK_FD(tt) == TASK_FD(t)) |
| continue; | |
| else | |
| flg++; | flg++; |
| #ifdef __NetBSD__ | #ifdef __NetBSD__ |
| EV_SET(&chg[0], TASK_FD(t), EVFILT_VNODE, flg < 2 ? EV_DELETE : 0, | EV_SET(&chg[0], TASK_FD(t), EVFILT_VNODE, flg < 2 ? EV_DELETE : 0, |
| Line 344 sched_hook_cancel(void *task, void *arg __unused) | Line 330 sched_hook_cancel(void *task, void *arg __unused) |
| case taskPROC: | case taskPROC: |
| #if SUP_ENABLE == KQ_SUPPORT | #if SUP_ENABLE == KQ_SUPPORT |
| /* check for multi subscribers */ | /* check for multi subscribers */ |
| flg = 0; | |
| TAILQ_FOREACH_SAFE(tt, &r->root_proc, task_node, tmp) | TAILQ_FOREACH_SAFE(tt, &r->root_proc, task_node, tmp) |
| if (TASK_VAL(tt) != TASK_VAL(t)) | if (TASK_VAL(tt) == TASK_VAL(t)) |
| continue; | |
| else | |
| flg++; | flg++; |
| #ifdef __NetBSD__ | #ifdef __NetBSD__ |
| EV_SET(&chg[0], TASK_VAL(t), EVFILT_PROC, flg < 2 ? EV_DELETE : 0, | EV_SET(&chg[0], TASK_VAL(t), EVFILT_PROC, flg < 2 ? EV_DELETE : 0, |
| Line 362 sched_hook_cancel(void *task, void *arg __unused) | Line 345 sched_hook_cancel(void *task, void *arg __unused) |
| case taskSIGNAL: | case taskSIGNAL: |
| #if SUP_ENABLE == KQ_SUPPORT | #if SUP_ENABLE == KQ_SUPPORT |
| /* check for multi subscribers */ | /* check for multi subscribers */ |
| flg = 0; | |
| TAILQ_FOREACH_SAFE(tt, &r->root_signal, task_node, tmp) | TAILQ_FOREACH_SAFE(tt, &r->root_signal, task_node, tmp) |
| if (TASK_VAL(tt) != TASK_VAL(t)) | if (TASK_VAL(tt) == TASK_VAL(t)) |
| continue; | |
| else | |
| flg++; | flg++; |
| #ifdef __NetBSD__ | #ifdef __NetBSD__ |
| EV_SET(&chg[0], TASK_VAL(t), EVFILT_SIGNAL, flg < 2 ? EV_DELETE : 0, | EV_SET(&chg[0], TASK_VAL(t), EVFILT_SIGNAL, flg < 2 ? EV_DELETE : 0, |
| Line 384 sched_hook_cancel(void *task, void *arg __unused) | Line 364 sched_hook_cancel(void *task, void *arg __unused) |
| case taskAIO: | case taskAIO: |
| #if SUP_ENABLE == KQ_SUPPORT | #if SUP_ENABLE == KQ_SUPPORT |
| /* check for multi subscribers */ | /* check for multi subscribers */ |
| flg = 0; | |
| TAILQ_FOREACH_SAFE(tt, &r->root_aio, task_node, tmp) | TAILQ_FOREACH_SAFE(tt, &r->root_aio, task_node, tmp) |
| if (TASK_VAL(tt) != TASK_VAL(t)) | if (TASK_VAL(tt) == TASK_VAL(t)) |
| continue; | |
| else | |
| flg++; | flg++; |
| #ifdef __NetBSD__ | #ifdef __NetBSD__ |
| EV_SET(&chg[0], TASK_VAL(t), EVFILT_AIO, flg < 2 ? EV_DELETE : 0, | EV_SET(&chg[0], TASK_VAL(t), EVFILT_AIO, flg < 2 ? EV_DELETE : 0, |
| Line 401 sched_hook_cancel(void *task, void *arg __unused) | Line 378 sched_hook_cancel(void *task, void *arg __unused) |
| if (acb) { | if (acb) { |
| if (aio_cancel(acb->aio_fildes, acb) == AIO_CANCELED) | if (aio_cancel(acb->aio_fildes, acb) == AIO_CANCELED) |
| aio_return(acb); | aio_return(acb); |
| free(acb); | e_free(acb); |
| TASK_VAL(t) = 0; | TASK_VAL(t) = 0; |
| } | } |
| #endif | #endif |
| Line 410 sched_hook_cancel(void *task, void *arg __unused) | Line 387 sched_hook_cancel(void *task, void *arg __unused) |
| case taskLIO: | case taskLIO: |
| #if SUP_ENABLE == KQ_SUPPORT | #if SUP_ENABLE == KQ_SUPPORT |
| /* check for multi subscribers */ | /* check for multi subscribers */ |
| flg = 0; | |
| TAILQ_FOREACH_SAFE(tt, &r->root_lio, task_node, tmp) | TAILQ_FOREACH_SAFE(tt, &r->root_lio, task_node, tmp) |
| if (TASK_VAL(tt) != TASK_VAL(t)) | if (TASK_VAL(tt) == TASK_VAL(t)) |
| continue; | |
| else | |
| flg++; | flg++; |
| #ifdef __NetBSD__ | #ifdef __NetBSD__ |
| EV_SET(&chg[0], TASK_VAL(t), EVFILT_LIO, flg < 2 ? EV_DELETE : 0, | EV_SET(&chg[0], TASK_VAL(t), EVFILT_LIO, flg < 2 ? EV_DELETE : 0, |
| Line 428 sched_hook_cancel(void *task, void *arg __unused) | Line 402 sched_hook_cancel(void *task, void *arg __unused) |
| for (i = 0; i < TASK_DATLEN(t); i++) { | for (i = 0; i < TASK_DATLEN(t); i++) { |
| if (aio_cancel(acbs[i]->aio_fildes, acbs[i]) == AIO_CANCELED) | if (aio_cancel(acbs[i]->aio_fildes, acbs[i]) == AIO_CANCELED) |
| aio_return(acbs[i]); | aio_return(acbs[i]); |
| free(acbs[i]); | e_free(acbs[i]); |
| } | } |
| free(acbs); | e_free(acbs); |
| TASK_VAL(t) = 0; | TASK_VAL(t) = 0; |
| } | } |
| #endif | #endif |
| Line 441 sched_hook_cancel(void *task, void *arg __unused) | Line 415 sched_hook_cancel(void *task, void *arg __unused) |
| case taskUSER: | case taskUSER: |
| #if SUP_ENABLE == KQ_SUPPORT | #if SUP_ENABLE == KQ_SUPPORT |
| /* check for multi subscribers */ | /* check for multi subscribers */ |
| flg = 0; | |
| TAILQ_FOREACH_SAFE(tt, &r->root_user, task_node, tmp) | TAILQ_FOREACH_SAFE(tt, &r->root_user, task_node, tmp) |
| if (TASK_VAL(tt) != TASK_VAL(t)) | if (TASK_VAL(tt) == TASK_VAL(t)) |
| continue; | |
| else | |
| flg++; | flg++; |
| #ifdef __NetBSD__ | #ifdef __NetBSD__ |
| EV_SET(&chg[0], TASK_VAL(t), EVFILT_USER, flg < 2 ? EV_DELETE : 0, | EV_SET(&chg[0], TASK_VAL(t), EVFILT_USER, flg < 2 ? EV_DELETE : 0, |
| Line 477 sched_hook_cancel(void *task, void *arg __unused) | Line 448 sched_hook_cancel(void *task, void *arg __unused) |
| schedCancel((sched_task_t*) TASK_RET(t)); | schedCancel((sched_task_t*) TASK_RET(t)); |
| #else | #else |
| /* check for multi subscribers */ | /* check for multi subscribers */ |
| flg = 0; | |
| TAILQ_FOREACH_SAFE(tt, &r->root_rtc, task_node, tmp) | TAILQ_FOREACH_SAFE(tt, &r->root_rtc, task_node, tmp) |
| if (TASK_DATA(tt) != TASK_DATA(t)) | if (TASK_DATA(tt) == TASK_DATA(t)) |
| continue; | |
| else | |
| flg++; | flg++; |
| /* restore signal */ | /* restore signal */ |
| Line 497 sched_hook_cancel(void *task, void *arg __unused) | Line 465 sched_hook_cancel(void *task, void *arg __unused) |
| #if SUP_ENABLE == KQ_SUPPORT | #if SUP_ENABLE == KQ_SUPPORT |
| kevent(r->root_kq, chg, 1, NULL, 0, &timeout); | kevent(r->root_kq, chg, 1, NULL, 0, &timeout); |
| #elif SUP_ENABLE == EP_SUPPORT | #elif SUP_ENABLE == EP_SUPPORT |
| epoll_ctl(r->root_kq, ee.events ? EPOLL_CTL_MOD : EPOLL_CTL_DEL, ee.data.fd, &ee); | if (TASK_TYPE(t) == taskREAD || TASK_TYPE(t) == taskWRITE) { |
| epoll_ctl(r->root_kq, ee.events ? EPOLL_CTL_MOD : EPOLL_CTL_DEL, ee.data.fd, &ee); | |
| } | |
| #endif | #endif |
| return NULL; | return NULL; |
| } | } |
| Line 650 sched_hook_write(void *task, void *arg __unused) | Line 620 sched_hook_write(void *task, void *arg __unused) |
| flg |= 1; | flg |= 1; |
| ee.events |= EPOLLIN | EPOLLPRI; | 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; |
| } | |
| 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) |
| Line 1015 fetch_hook_kevent_proceed(int en, struct kevent *res, | Line 986 fetch_hook_kevent_proceed(int en, struct kevent *res, |
| LOGERR; | LOGERR; |
| } else | } else |
| LOGERR; | LOGERR; |
| free(acb); | e_free(acb); |
| TASK_DATLEN(task) = (u_long) len; | TASK_DATLEN(task) = (u_long) len; |
| TASK_FD(task) = fd; | TASK_FD(task) = fd; |
| } | } |
| Line 1043 fetch_hook_kevent_proceed(int en, struct kevent *res, | Line 1014 fetch_hook_kevent_proceed(int en, struct kevent *res, |
| l = 0; | l = 0; |
| else | else |
| l = iv[i].iov_len; | l = iv[i].iov_len; |
| free(acbs[i]); | e_free(acbs[i]); |
| } | } |
| free(acbs); | e_free(acbs); |
| TASK_DATLEN(task) = (u_long) len; | TASK_DATLEN(task) = (u_long) len; |
| TASK_FD(task) = fd; | TASK_FD(task) = fd; |
| Line 1093 fetch_hook_kevent_proceed(int en, struct kevent *res, | Line 1064 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, rflg, wflg; |
| int ops = EPOLL_CTL_DEL; | int ops = EPOLL_CTL_DEL; |
| sched_task_t *t, *tmp, *task; | 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); |
| evt->events ^= evt->events; | |
| rflg = wflg = 0; | |
| if (evt->events & (EPOLLIN | EPOLLPRI)) { | if (res[i].events & (EPOLLIN | EPOLLPRI)) { |
| flg = 0; | |
| task = NULL; | task = NULL; |
| TAILQ_FOREACH_SAFE(t, &r->root_read, task_node, tmp) { | TAILQ_FOREACH_SAFE(t, &r->root_read, task_node, tmp) { |
| if (TASK_FD(t) == evt->data.fd) { | if (TASK_FD(t) == evt->data.fd) { |
| if (!flg) | if (!task) |
| task = t; | task = t; |
| flg++; | rflg++; |
| } | } |
| } | } |
| if (flg && task) { | if (task) { |
| TASK_FLAG(task) = ioctl(TASK_FD(task), FIONREAD, &TASK_RET(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 1131 fetch_hook_epoll_proceed(int en, struct epoll_event *r | Line 1103 fetch_hook_epoll_proceed(int en, struct epoll_event *r |
| insert_task_to(task, &r->root_ready); | insert_task_to(task, &r->root_ready); |
| } | } |
| evt->events ^= evt->events; | if (!(res[i].events & EPOLLOUT) && FD_ISSET(evt->data.fd, &r->root_fds[1])) { |
| if (FD_ISSET(evt->data.fd, &r->root_fds[1])) { | |
| ops = EPOLL_CTL_MOD; | |
| evt->events |= EPOLLOUT; | evt->events |= EPOLLOUT; |
| wflg = 42; | |
| } | } |
| if (flg > 1) { | if (rflg > 1) |
| ops = EPOLL_CTL_MOD; | |
| evt->events |= EPOLLIN | EPOLLPRI; | evt->events |= EPOLLIN | EPOLLPRI; |
| } else | else |
| FD_CLR(evt->data.fd, &r->root_fds[0]); | FD_CLR(evt->data.fd, &r->root_fds[0]); |
| } | } |
| } else if (evt->events & EPOLLOUT) { | } |
| flg = 0; | if (res[i].events & EPOLLOUT) { |
| task = NULL; | task = NULL; |
| TAILQ_FOREACH_SAFE(t, &r->root_write, task_node, tmp) { | TAILQ_FOREACH_SAFE(t, &r->root_write, task_node, tmp) { |
| if (TASK_FD(t) == evt->data.fd) { | if (TASK_FD(t) == evt->data.fd) { |
| if (!flg) | if (!task) |
| task = t; | task = t; |
| flg++; | wflg++; |
| } | } |
| } | } |
| if (flg && task) { | if (task) { |
| TASK_FLAG(task) = ioctl(TASK_FD(task), FIONWRITE, &TASK_RET(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 1172 fetch_hook_epoll_proceed(int en, struct epoll_event *r | Line 1142 fetch_hook_epoll_proceed(int en, struct epoll_event *r |
| insert_task_to(task, &r->root_ready); | insert_task_to(task, &r->root_ready); |
| } | } |
| evt->events ^= evt->events; | if (!(res[i].events & (EPOLLIN | EPOLLPRI)) && FD_ISSET(evt->data.fd, &r->root_fds[0])) { |
| if (FD_ISSET(evt->data.fd, &r->root_fds[0])) { | |
| ops = EPOLL_CTL_MOD; | |
| evt->events |= EPOLLIN | EPOLLPRI; | evt->events |= EPOLLIN | EPOLLPRI; |
| rflg = 42; | |
| } | } |
| if (flg > 1) { | if (wflg > 1) |
| ops = EPOLL_CTL_MOD; | |
| evt->events |= EPOLLOUT; | evt->events |= EPOLLOUT; |
| } else | else |
| FD_CLR(evt->data.fd, &r->root_fds[1]); | FD_CLR(evt->data.fd, &r->root_fds[1]); |
| } | } |
| } | } |
| if (rflg > 1 || wflg > 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) { |
| if (errno == EBADF) { | |
| epoll_ctl(r->root_kq, EPOLL_CTL_DEL, evt->data.fd, evt); | |
| schedCancelby(r, taskREAD, CRITERIA_FD, | |
| (void*) (uintptr_t) evt->data.fd, NULL); | |
| schedCancelby(r, taskWRITE, CRITERIA_FD, | |
| (void*) (uintptr_t) evt->data.fd, NULL); | |
| } | |
| 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); |
| } else | } else |
| Line 1206 fetch_hook_epoll_proceed(int en, struct epoll_event *r | Line 1170 fetch_hook_epoll_proceed(int en, struct epoll_event *r |
| static inline void | 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, rflg, wflg; |
| sched_task_t *t, *tmp, *task = NULL; | sched_task_t *t, *tmp, *task; |
| /* skip select check if return value from select is zero */ | /* skip select check if return value from select is zero */ |
| if (!en) | if (!en) |
| return; | return; |
| for (i = 0; i < r->root_kq; i++) { | for (i = 0; i < r->root_kq; i++) { |
| if (!FD_ISSET(i, &r->root_fds[0]) && !FD_ISSET(i, &r->root_fds[1])) | |
| continue; | |
| rflg = wflg = 0; | |
| if (FD_ISSET(i, &rfd) || FD_ISSET(i, &xfd)) { | if (FD_ISSET(i, &rfd) || FD_ISSET(i, &xfd)) { |
| flg = 0; | task = NULL; |
| TAILQ_FOREACH_SAFE(t, &r->root_read, task_node, tmp) { | TAILQ_FOREACH_SAFE(t, &r->root_read, task_node, tmp) { |
| if (TASK_FD(t) == i) { | if (TASK_FD(t) == i) { |
| if (!flg) | if (!task) |
| task = t; | task = t; |
| flg++; | rflg++; |
| } | } |
| } | } |
| if (flg && task) { | if (task) { |
| TASK_FLAG(task) = ioctl(TASK_FD(task), FIONREAD, &TASK_RET(task)); | TASK_FLAG(task) = ioctl(TASK_FD(task), FIONREAD, &TASK_RET(task)); |
| /* remove read handle */ | /* remove read handle */ |
| Line 1244 fetch_hook_select_proceed(int en, fd_set rfd, fd_set w | Line 1213 fetch_hook_select_proceed(int en, fd_set rfd, fd_set w |
| } | } |
| /* remove resouce */ | /* remove resouce */ |
| if (flg == 1) | if (rflg == 1) |
| FD_CLR(i, &r->root_fds[0]); | FD_CLR(i, &r->root_fds[0]); |
| } | } |
| } else if (FD_ISSET(i, &wfd)) { | } |
| flg = 0; | if (FD_ISSET(i, &wfd)) { |
| task = NULL; | |
| TAILQ_FOREACH_SAFE(t, &r->root_write, task_node, tmp) { | TAILQ_FOREACH_SAFE(t, &r->root_write, task_node, tmp) { |
| if (TASK_FD(t) == i) { | if (TASK_FD(t) == i) { |
| if (!flg) | if (!task) |
| task = t; | task = t; |
| flg++; | wflg++; |
| } | } |
| } | } |
| if (flg && task) { | if (task) { |
| TASK_FLAG(task) = ioctl(TASK_FD(task), FIONWRITE, &TASK_RET(task)); | TASK_FLAG(task) = ioctl(TASK_FD(task), FIONWRITE, &TASK_RET(task)); |
| /* remove write handle */ | /* remove write handle */ |
| Line 1277 fetch_hook_select_proceed(int en, fd_set rfd, fd_set w | Line 1247 fetch_hook_select_proceed(int en, fd_set rfd, fd_set w |
| } | } |
| /* remove resouce */ | /* remove resouce */ |
| if (flg == 1) | if (wflg == 1) |
| FD_CLR(i, &r->root_fds[1]); | FD_CLR(i, &r->root_fds[1]); |
| } | } |
| } | } |
| } | } |
| /* optimize select */ | /* optimize select */ |
| for (i = r->root_kq - 1; i > 2; i--) | for (i = r->root_kq - 1; i >= 0; i--) |
| if (FD_ISSET(i, &r->root_fds[0]) || FD_ISSET(i, &r->root_fds[1])) | if (FD_ISSET(i, &r->root_fds[0]) || FD_ISSET(i, &r->root_fds[1])) |
| break; | break; |
| if (i > 2) | r->root_kq = i + 1; |
| r->root_kq = i + 1; | |
| } | } |
| #endif | #endif |