… | |
… | |
142 | } |
142 | } |
143 | |
143 | |
144 | static void |
144 | static void |
145 | x_cb_sig (EV_P_ struct ev_signal *w, int revents) |
145 | x_cb_sig (EV_P_ struct ev_signal *w, int revents) |
146 | { |
146 | { |
147 | x_cb ((struct event *)(((char *)w) - offsetof (struct event, iosig.sig)), revents); |
147 | struct event *ev = (struct event *)(((char *)w) - offsetof (struct event, iosig.sig)); |
|
|
148 | |
|
|
149 | if (revents & EV_ERROR) |
|
|
150 | event_del (ev); |
|
|
151 | |
|
|
152 | x_cb (ev, revents); |
148 | } |
153 | } |
149 | |
154 | |
150 | static void |
155 | static void |
151 | x_cb_io (EV_P_ struct ev_io *w, int revents) |
156 | x_cb_io (EV_P_ struct ev_io *w, int revents) |
152 | { |
157 | { |
153 | struct event *ev = (struct event *)(((char *)w) - offsetof (struct event, iosig.io)); |
158 | struct event *ev = (struct event *)(((char *)w) - offsetof (struct event, iosig.io)); |
154 | |
159 | |
|
|
160 | if (revents & EV_ERROR) |
|
|
161 | event_del (ev); |
155 | if (!(ev->ev_events & EV_PERSIST) && ev_is_active (w)) |
162 | else if (!(ev->ev_events & EV_PERSIST) && ev_is_active (w)) |
156 | ev_io_stop (EV_A_ w); |
163 | ev_io_stop (EV_A_ w); |
157 | |
164 | |
158 | x_cb (ev, revents); |
165 | x_cb (ev, revents); |
159 | } |
166 | } |
160 | |
167 | |
… | |
… | |
330 | }; |
337 | }; |
331 | |
338 | |
332 | static void |
339 | static void |
333 | x_once_cb (int revents, void *arg) |
340 | x_once_cb (int revents, void *arg) |
334 | { |
341 | { |
335 | struct x_once *once = arg; |
342 | struct x_once *once = (struct x_once *)arg; |
336 | |
343 | |
337 | once->cb (once->fd, revents, once->arg); |
344 | once->cb (once->fd, revents, once->arg); |
338 | free (once); |
345 | free (once); |
339 | } |
346 | } |
340 | |
347 | |
341 | int event_base_once (struct event_base *base, int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv) |
348 | int event_base_once (struct event_base *base, int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv) |
342 | { |
349 | { |
343 | struct x_once *once = malloc (sizeof (struct x_once)); |
350 | struct x_once *once = (struct x_once *)malloc (sizeof (struct x_once)); |
344 | dLOOPbase; |
351 | dLOOPbase; |
345 | |
352 | |
346 | if (!once) |
353 | if (!once) |
347 | return -1; |
354 | return -1; |
348 | |
355 | |