--- cvsroot/EV-ADNS/ADNS.xs 2007/12/01 22:36:10 1.9 +++ cvsroot/EV-ADNS/ADNS.xs 2007/12/07 23:54:13 1.12 @@ -7,9 +7,6 @@ #include "EVAPI.h" -static HV *stash; -static adns_state ads; - struct ctx { SV *self; @@ -28,7 +25,7 @@ } static void -process () +process (adns_state ads) { dSP; @@ -218,7 +215,7 @@ static ev_io *iow; static ev_timer tw; static ev_idle iw; -static ev_prepare prepare_ev; +static ev_prepare pw; static struct timeval tv_now; static void @@ -227,7 +224,7 @@ ev_tstamp t = ev_now (); tv_now.tv_sec = (long)t; - tv_now.tv_usec = (long)((t - (ev_tstamp)tv_now.tv_sec) * 1e-6); + tv_now.tv_usec = (long)((t - (ev_tstamp)tv_now.tv_sec) * 1e6); } static void @@ -239,11 +236,16 @@ static void timer_cb (EV_P_ ev_timer *w, int revents) { + adns_state ads = (adns_state)w->data; + update_now (); + + adns_processtimeouts (ads, &tv_now); } static void io_cb (EV_P_ ev_io *w, int revents) { + adns_state ads = (adns_state)w->data; update_now (EV_A); if (revents & EV_READ ) adns_processreadable (ads, w->fd, &tv_now); @@ -256,6 +258,7 @@ { int i; int timeout = 3600000; + adns_state ads = (adns_state)w->data; if (ev_is_active (&tw)) { @@ -272,8 +275,7 @@ ev_io_stop (EV_A_ iow + i); } - process (); - + process (ads); update_now (EV_A); nfd = mfd; @@ -302,6 +304,9 @@ } } +static HV *stash; +static adns_state ads; + MODULE = EV::ADNS PACKAGE = EV::ADNS PROTOTYPES: ENABLE @@ -398,14 +403,17 @@ I_EV_API ("EV::ADNS"); - ev_prepare_init (&prepare_ev, prepare_cb); - ev_prepare_start (EV_DEFAULT_ &prepare_ev); + adns_init (&ads, adns_if_noenv | adns_if_noerrprint | adns_if_noserverwarn | adns_if_noautosys, 0); + + ev_prepare_init (&pw, prepare_cb); + pw.data = (void *)ads; + ev_prepare_start (EV_DEFAULT_ &pw); ev_unref (); - ev_init (&iw, idle_cb); + ev_init (&iw, idle_cb); ev_set_priority (&iw, EV_MINPRI); + iw.data = (void *)ads; ev_init (&tw, timer_cb); - - adns_init (&ads, adns_if_noenv | adns_if_noerrprint | adns_if_noserverwarn | adns_if_noautosys, 0); + tw.data = (void *)ads; } void submit (char *owner, int type, int flags, SV *cb)