Changeset 35030
- Timestamp:
- 08/24/09 21:46:13 (4 years ago)
- Files:
-
- 1 modified
-
lang/c/picoev/trunk/picoev_epoll.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/c/picoev/trunk/picoev_epoll.c
r35029 r35030 28 28 */ 29 29 30 #include <errno.h> 30 31 #include <sys/epoll.h> 31 32 #include <unistd.h> … … 55 56 socket was reopened, it might require re-assigning */ 56 57 int old_events = BACKEND_GET_OLD_EVENTS(target->_backend); 57 if ( target->events == 0) {58 if (old_events != 0 && target->events == 0) { 58 59 epoll_ctl(loop->epfd, EPOLL_CTL_DEL, fd, 0); 59 60 } else { 60 61 struct epoll_event ev; 62 int r; 61 63 ev.events = ((target->events & PICOEV_READ) != 0 ? EPOLLIN : 0) 62 64 | ((target->events & PICOEV_WRITE) != 0 ? EPOLLOUT : 0); 63 65 ev.data.fd = fd; 64 if (old_events == 0 65 || epoll_ctl(loop->epfd, EPOLL_CTL_MOD, fd, &ev) != 0) { 66 int r = epoll_ctl(loop->epfd, EPOLL_CTL_ADD, fd, &ev); 67 assert(r == 0); 66 if (old_events != 0) { 67 if (epoll_ctl(loop->epfd, EPOLL_CTL_MOD, fd, &ev) != 0) { 68 assert(errno == ENOENT); 69 r = epoll_ctl(loop->epfd, EPOLL_CTL_ADD, fd, &ev); 70 assert(r == 0); 71 } 72 } else { 73 if (epoll_ctl(loop->epfd, EPOLL_CTL_ADD, fd, &ev) != 0) { 74 assert(errno == EEXIST); 75 r = epoll_ctl(loop->epfd, EPOLL_CTL_MOD, fd, &ev); 76 assert(r == 0); 77 } 68 78 } 69 79 } … … 177 187 target->cb_arg); 178 188 } else { 179 CALL_EPOLL(loop->epfd, EPOLL_CTL_DEL, event->data.fd, 0);189 epoll_ctl(loop->epfd, EPOLL_CTL_DEL, event->data.fd, 0); 180 190 } 181 191 }
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)