… | |
… | |
84 | } |
84 | } |
85 | |
85 | |
86 | static void |
86 | static void |
87 | poll_poll (EV_P_ ev_tstamp timeout) |
87 | poll_poll (EV_P_ ev_tstamp timeout) |
88 | { |
88 | { |
89 | int i; |
89 | struct pollfd *p; |
90 | int res = poll (polls, pollcnt, (int)ceil (timeout * 1000.)); |
90 | int res = poll (polls, pollcnt, (int)ceil (timeout * 1000.)); |
91 | |
91 | |
92 | if (expect_false (res < 0)) |
92 | if (expect_false (res < 0)) |
93 | { |
93 | { |
94 | if (errno == EBADF) |
94 | if (errno == EBADF) |
… | |
… | |
96 | else if (errno == ENOMEM && !syserr_cb) |
96 | else if (errno == ENOMEM && !syserr_cb) |
97 | fd_enomem (EV_A); |
97 | fd_enomem (EV_A); |
98 | else if (errno != EINTR) |
98 | else if (errno != EINTR) |
99 | syserr ("(libev) poll"); |
99 | syserr ("(libev) poll"); |
100 | } |
100 | } |
101 | else if (res > 0) |
101 | |
102 | for (i = 0; i < pollcnt; ++i) |
102 | for (p = polls; res; ++p) |
|
|
103 | if (expect_false (p->revents)) /* this expect is debatable */ |
|
|
104 | { |
|
|
105 | --res; |
|
|
106 | |
103 | if (expect_false (polls [i].revents & POLLNVAL)) |
107 | if (expect_false (p->revents & POLLNVAL)) |
104 | fd_kill (EV_A_ polls [i].fd); |
108 | fd_kill (EV_A_ p->fd); |
105 | else |
109 | else |
106 | fd_event ( |
110 | fd_event ( |
107 | EV_A_ |
111 | EV_A_ |
108 | polls [i].fd, |
112 | p->fd, |
109 | (polls [i].revents & (POLLOUT | POLLERR | POLLHUP) ? EV_WRITE : 0) |
113 | (p->revents & (POLLOUT | POLLERR | POLLHUP) ? EV_WRITE : 0) |
110 | | (polls [i].revents & (POLLIN | POLLERR | POLLHUP) ? EV_READ : 0) |
114 | | (p->revents & (POLLIN | POLLERR | POLLHUP) ? EV_READ : 0) |
111 | ); |
115 | ); |
|
|
116 | } |
112 | } |
117 | } |
113 | |
118 | |
114 | int inline_size |
119 | int inline_size |
115 | poll_init (EV_P_ int flags) |
120 | poll_init (EV_P_ int flags) |
116 | { |
121 | { |