… | |
… | |
34 | #include <poll.h> |
34 | #include <poll.h> |
35 | #include <port.h> |
35 | #include <port.h> |
36 | #include <string.h> |
36 | #include <string.h> |
37 | #include <errno.h> |
37 | #include <errno.h> |
38 | |
38 | |
|
|
39 | void inline_speed |
|
|
40 | port_associate_and_check (EV_P_ int fd, int ev) |
|
|
41 | { |
|
|
42 | if (0 > |
|
|
43 | port_associate ( |
|
|
44 | backend_fd, PORT_SOURCE_FD, fd, |
|
|
45 | (ev & EV_READ ? POLLIN : 0) |
|
|
46 | | (ev & EV_WRITE ? POLLOUT : 0), |
|
|
47 | 0 |
|
|
48 | ) |
|
|
49 | ) |
|
|
50 | { |
|
|
51 | if (errno == EBADFD) |
|
|
52 | fd_kill (EV_A_ fd); |
|
|
53 | else |
|
|
54 | syserr ("(libev) port_associate"); |
|
|
55 | } |
|
|
56 | } |
|
|
57 | |
39 | static void |
58 | static void |
40 | port_modify (EV_P_ int fd, int oev, int nev) |
59 | port_modify (EV_P_ int fd, int oev, int nev) |
41 | { |
60 | { |
42 | /* we need to reassociate no matter what, as closes are |
61 | /* we need to reassociate no matter what, as closes are |
43 | * once more silently being discarded. |
62 | * once more silently being discarded. |
… | |
… | |
45 | if (!nev) |
64 | if (!nev) |
46 | { |
65 | { |
47 | if (oev) |
66 | if (oev) |
48 | port_dissociate (backend_fd, PORT_SOURCE_FD, fd); |
67 | port_dissociate (backend_fd, PORT_SOURCE_FD, fd); |
49 | } |
68 | } |
50 | else if (0 > |
|
|
51 | port_associate ( |
|
|
52 | backend_fd, PORT_SOURCE_FD, fd, |
|
|
53 | (nev & EV_READ ? POLLIN : 0) |
|
|
54 | | (nev & EV_WRITE ? POLLOUT : 0), |
|
|
55 | 0 |
|
|
56 | ) |
|
|
57 | ) |
|
|
58 | { |
|
|
59 | if (errno == EBADFD) |
|
|
60 | fd_kill (EV_A_ fd); |
|
|
61 | else |
69 | else |
62 | syserr ("(libev) port_associate"); |
70 | port_associate_and_check (EV_A_ fd, nev); |
63 | } |
|
|
64 | } |
71 | } |
65 | |
72 | |
66 | static void |
73 | static void |
67 | port_poll (EV_P_ ev_tstamp timeout) |
74 | port_poll (EV_P_ ev_tstamp timeout) |
68 | { |
75 | { |
… | |
… | |
93 | fd, |
100 | fd, |
94 | (port_events [i].portev_events & (POLLOUT | POLLERR | POLLHUP) ? EV_WRITE : 0) |
101 | (port_events [i].portev_events & (POLLOUT | POLLERR | POLLHUP) ? EV_WRITE : 0) |
95 | | (port_events [i].portev_events & (POLLIN | POLLERR | POLLHUP) ? EV_READ : 0) |
102 | | (port_events [i].portev_events & (POLLIN | POLLERR | POLLHUP) ? EV_READ : 0) |
96 | ); |
103 | ); |
97 | |
104 | |
98 | anfds [fd].events = 0; /* event received == disassociated */ |
105 | port_associate_and_check (EV_A_ fd, anfds [fd].events); |
99 | fd_change (EV_A_ fd); /* need to reify later */ |
|
|
100 | } |
106 | } |
101 | } |
107 | } |
102 | |
108 | |
103 | if (expect_false (nget == port_eventmax)) |
109 | if (expect_false (nget == port_eventmax)) |
104 | { |
110 | { |