ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/EV-ADNS/ADNS.xs
(Generate patch)

Comparing EV-ADNS/ADNS.xs (file contents):
Revision 1.8 by root, Sat Dec 1 21:29:08 2007 UTC vs.
Revision 1.9 by root, Sat Dec 1 22:36:10 2007 UTC

215 215
216static struct pollfd *fds; 216static struct pollfd *fds;
217static int nfd, mfd; 217static int nfd, mfd;
218static ev_io *iow; 218static ev_io *iow;
219static ev_timer tw; 219static ev_timer tw;
220static ev_idle iw;
220static ev_prepare prepare_ev; 221static ev_prepare prepare_ev;
221static struct timeval tv_now; 222static struct timeval tv_now;
222 223
223static void 224static void
224update_now (EV_P) 225update_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
233static void
234idle_cb (EV_P_ ev_idle *w, int revents)
235{
236 ev_idle_stop (EV_A_ w);
230} 237}
231 238
232static void 239static void
233timer_cb (EV_P_ ev_timer *w, int revents) 240timer_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);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines