… | |
… | |
215 | |
215 | |
216 | static struct pollfd *fds; |
216 | static struct pollfd *fds; |
217 | static int nfd, mfd; |
217 | static int nfd, mfd; |
218 | static ev_io *iow; |
218 | static ev_io *iow; |
219 | static ev_timer tw; |
219 | static ev_timer tw; |
|
|
220 | static ev_idle iw; |
220 | static ev_prepare prepare_ev; |
221 | static ev_prepare prepare_ev; |
221 | static struct timeval tv_now; |
222 | static struct timeval tv_now; |
222 | |
223 | |
223 | static void |
224 | static void |
224 | update_now (EV_P) |
225 | update_now (EV_P) |
225 | { |
226 | { |
226 | ev_tstamp t = ev_now (); |
227 | ev_tstamp t = ev_now (); |
227 | |
228 | |
228 | tv_now.tv_sec = (long)t; |
229 | tv_now.tv_sec = (long)t; |
229 | tv_now.tv_usec = (long)((t - (ev_tstamp)tv_now.tv_sec) * 1e-6); |
230 | tv_now.tv_usec = (long)((t - (ev_tstamp)tv_now.tv_sec) * 1e-6); |
|
|
231 | } |
|
|
232 | |
|
|
233 | static void |
|
|
234 | idle_cb (EV_P_ ev_idle *w, int revents) |
|
|
235 | { |
|
|
236 | ev_idle_stop (EV_A_ w); |
230 | } |
237 | } |
231 | |
238 | |
232 | static void |
239 | static void |
233 | timer_cb (EV_P_ ev_timer *w, int revents) |
240 | timer_cb (EV_P_ ev_timer *w, int revents) |
234 | { |
241 | { |
… | |
… | |
253 | if (ev_is_active (&tw)) |
260 | if (ev_is_active (&tw)) |
254 | { |
261 | { |
255 | ev_ref (); |
262 | ev_ref (); |
256 | ev_timer_stop (EV_A_ &tw); |
263 | ev_timer_stop (EV_A_ &tw); |
257 | } |
264 | } |
|
|
265 | |
|
|
266 | if (ev_is_active (&iw)) |
|
|
267 | ev_idle_stop (EV_A_ &iw); |
258 | |
268 | |
259 | for (i = 0; i < nfd; ++i) |
269 | for (i = 0; i < nfd; ++i) |
260 | { |
270 | { |
261 | ev_ref (); |
271 | ev_ref (); |
262 | ev_io_stop (EV_A_ iow + i); |
272 | ev_io_stop (EV_A_ iow + i); |
… | |
… | |
386 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
396 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
387 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
397 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
388 | |
398 | |
389 | I_EV_API ("EV::ADNS"); |
399 | I_EV_API ("EV::ADNS"); |
390 | |
400 | |
391 | ev_prepare_init (&prepare_ev, prepare_cb); ev_prepare_start (EV_DEFAULT_ &prepare_ev); |
401 | ev_prepare_init (&prepare_ev, prepare_cb); |
|
|
402 | ev_prepare_start (EV_DEFAULT_ &prepare_ev); |
392 | ev_unref (); |
403 | ev_unref (); |
393 | |
404 | |
|
|
405 | ev_init (&iw, idle_cb); |
394 | ev_init (&tw, timer_cb); |
406 | ev_init (&tw, timer_cb); |
395 | |
407 | |
396 | adns_init (&ads, adns_if_noenv | adns_if_noerrprint | adns_if_noserverwarn | adns_if_noautosys, 0); |
408 | adns_init (&ads, adns_if_noenv | adns_if_noerrprint | adns_if_noserverwarn | adns_if_noautosys, 0); |
397 | } |
409 | } |
398 | |
410 | |
… | |
… | |
416 | SvCUR_set (csv, sizeof (struct ctx)); |
428 | SvCUR_set (csv, sizeof (struct ctx)); |
417 | |
429 | |
418 | c->self = csv; |
430 | c->self = csv; |
419 | c->cb = newSVsv (cb); |
431 | c->cb = newSVsv (cb); |
420 | |
432 | |
|
|
433 | if (!ev_is_active (&iw)) |
|
|
434 | ev_idle_start (EV_A_ &iw); |
|
|
435 | |
421 | if (GIMME_V != G_VOID) |
436 | if (GIMME_V != G_VOID) |
422 | { |
437 | { |
423 | csv = sv_2mortal (newRV_inc (csv)); |
438 | csv = sv_2mortal (newRV_inc (csv)); |
424 | sv_bless (csv, stash); |
439 | sv_bless (csv, stash); |
425 | XPUSHs (csv); |
440 | XPUSHs (csv); |