Diff for /libaitsched/src/hooks.c between versions 1.30 and 1.31.2.3

version 1.30, 2015/07/02 23:27:06 version 1.31.2.3, 2017/08/31 12:22:16
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 - 2015Copyright 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 = { .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 1198  fetch_hook_select_proceed(int en, fd_set rfd, fd_set w Line 1208  fetch_hook_select_proceed(int en, fd_set rfd, fd_set w
                                 }                                  }
                         }                          }
                         /* remove resouce */                          /* remove resouce */
                        if (flg)                        if (flg == 1)
                                 FD_CLR(i, &r->root_fds[0]);                                  FD_CLR(i, &r->root_fds[0]);
                 }                  }
   
Line 1229  fetch_hook_select_proceed(int en, fd_set rfd, fd_set w Line 1239  fetch_hook_select_proceed(int en, fd_set rfd, fd_set w
                                 }                                  }
                         }                          }
                         /* remove resouce */                          /* remove resouce */
                        if (flg)                        if (flg == 1)
                                 FD_CLR(i, &r->root_fds[1]);                                  FD_CLR(i, &r->root_fds[1]);
                 }                  }
         }          }

Removed from v.1.30  
changed lines
  Added in v.1.31.2.3


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>