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

Comparing EV/EV.xs (file contents):
Revision 1.31 by root, Thu Nov 1 11:11:21 2007 UTC vs.
Revision 1.63 by root, Sat Nov 10 03:19:21 2007 UTC

2#include "perl.h" 2#include "perl.h"
3#include "XSUB.h" 3#include "XSUB.h"
4 4
5/*#include <netinet/in.h>*/ 5/*#include <netinet/in.h>*/
6 6
7#define TIMEOUT_NONE HUGE_VAL
8#define EV_USE_EPOLL 1
9
10#define EV_PROTOTYPES 1 7#define EV_PROTOTYPES 1
11#include "EV/EVAPI.h" 8#include "EV/EVAPI.h"
12 9
10/* fix perl api breakage */
11#undef signal
12#undef sigaction
13
14#define EV_SELECT_USE_WIN32_HANDLES 0
15#define EV_SELECT_USE_FD_SET 0
16/* due to bugs in OS X we have to use libev/ explicitly here */
13#include "libev/ev.c" 17#include "libev/ev.c"
18#include "event.c"
19
20#ifndef WIN32
21#define DNS_USE_GETTIMEOFDAY_FOR_ID 1
22#if !defined (WIN32) && !defined(__CYGWIN__)
23# define HAVE_STRUCT_IN6_ADDR 1
24#endif
25#undef HAVE_STRTOK_R
26#undef strtok_r
27#define strtok_r fake_strtok_r
28#include "evdns.h"
29#include "evdns.c"
30#endif
31
32#ifndef WIN32
33# include <pthread.h>
34#endif
14 35
15typedef int Signal; 36typedef int Signal;
16 37
17static struct EVAPI evapi; 38static struct EVAPI evapi;
18 39
25 *stash_idle, 46 *stash_idle,
26 *stash_prepare, 47 *stash_prepare,
27 *stash_check, 48 *stash_check,
28 *stash_child; 49 *stash_child;
29 50
51#ifndef SIG_SIZE
52/* kudos to Slaven Rezic for the idea */
53static char sig_size [] = { SIG_NUM };
54# define SIG_SIZE (sizeof (sig_size) + 1)
55#endif
56
30static int 57static int
31sv_signum (SV *sig) 58sv_signum (SV *sig)
32{ 59{
33 int signum; 60 int signum;
34 61
74 SvPOK_only (self); 101 SvPOK_only (self);
75 SvCUR_set (self, size); 102 SvCUR_set (self, size);
76 103
77 w = (struct ev_watcher *)SvPVX (self); 104 w = (struct ev_watcher *)SvPVX (self);
78 105
79 ev_watcher_init (w, e_cb); 106 ev_init (w, e_cb);
80 107
108 w->data = 0;
81 w->fh = 0; 109 w->fh = 0;
82 w->cb_sv = newSVsv (cb_sv); 110 w->cb_sv = newSVsv (cb_sv);
83 w->self = self; 111 w->self = self;
84 112
85 return (void *)w; 113 return (void *)w;
114}
115
116static void
117e_destroy (void *w_)
118{
119 struct ev_watcher *w = (struct ev_watcher *)w_;
120
121 SvREFCNT_dec (w->fh ); w->fh = 0;
122 SvREFCNT_dec (w->cb_sv); w->cb_sv = 0;
123 SvREFCNT_dec (w->data ); w->data = 0;
86} 124}
87 125
88static SV * 126static SV *
89e_bless (struct ev_watcher *w, HV *stash) 127e_bless (struct ev_watcher *w, HV *stash)
90{ 128{
108 dSP; 146 dSP;
109 I32 mark = SP - PL_stack_base; 147 I32 mark = SP - PL_stack_base;
110 SV *sv_self, *sv_events, *sv_status = 0; 148 SV *sv_self, *sv_events, *sv_status = 0;
111 static SV *sv_events_cache; 149 static SV *sv_events_cache;
112 150
113 fprintf (stderr, "e_cb %p,%x\n", w, revents);//D
114
115 sv_self = newRV_inc (w->self); /* w->self MUST be blessed by now */ 151 sv_self = newRV_inc (w->self); /* w->self MUST be blessed by now */
116 152
117 if (sv_events_cache) 153 if (sv_events_cache)
118 { 154 {
119 sv_events = sv_events_cache; sv_events_cache = 0; 155 sv_events = sv_events_cache; sv_events_cache = 0;
125 PUSHMARK (SP); 161 PUSHMARK (SP);
126 EXTEND (SP, 2); 162 EXTEND (SP, 2);
127 PUSHs (sv_self); 163 PUSHs (sv_self);
128 PUSHs (sv_events); 164 PUSHs (sv_events);
129 165
130 if (revents & EV_CHILD)
131 XPUSHs (sv_status = newSViv (((struct ev_child *)w)->status));
132
133 PUTBACK; 166 PUTBACK;
134 call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); 167 call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL);
135 SP = PL_stack_base + mark; PUTBACK; 168 SP = PL_stack_base + mark; PUTBACK;
136 169
137 SvREFCNT_dec (sv_self); 170 SvREFCNT_dec (sv_self);
149 call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); 182 call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR);
150 SP = PL_stack_base + mark; PUTBACK; 183 SP = PL_stack_base + mark; PUTBACK;
151 } 184 }
152} 185}
153 186
154#if 0 187static ev_tstamp
188e_periodic_cb (struct ev_periodic *w, ev_tstamp now)
189{
190 ev_tstamp retval;
191 int count;
192 dSP;
193
194 ENTER;
195 SAVETMPS;
196
197 PUSHMARK (SP);
198 EXTEND (SP, 2);
199 PUSHs (newRV_inc (w->self)); /* w->self MUST be blessed by now */
200 PUSHs (newSVnv (now));
201
202 PUTBACK;
203 count = call_sv (w->fh, G_SCALAR | G_EVAL);
204 SPAGAIN;
205
206 if (SvTRUE (ERRSV))
207 {
208 PUSHMARK (SP);
209 PUTBACK;
210 call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR);
211 SPAGAIN;
212 }
213
214 if (count > 0)
215 {
216 retval = SvNV (TOPs);
217
218 if (retval < now)
219 retval = now;
220 }
221 else
222 retval = now;
223
224 FREETMPS;
225 LEAVE;
226
227 return retval;
228}
229
155///////////////////////////////////////////////////////////////////////////// 230/////////////////////////////////////////////////////////////////////////////
156// DNS 231// DNS
157 232
233#ifndef WIN32
158static void 234static void
159dns_cb (int result, char type, int count, int ttl, void *addresses, void *arg) 235dns_cb (int result, char type, int count, int ttl, void *addresses, void *arg)
160{ 236{
161 dSP; 237 dSP;
162 SV *cb = (SV *)arg; 238 SV *cb = (SV *)arg;
218 294
219PROTOTYPES: ENABLE 295PROTOTYPES: ENABLE
220 296
221BOOT: 297BOOT:
222{ 298{
223 int i;
224 HV *stash = gv_stashpv ("EV", 1); 299 HV *stash = gv_stashpv ("EV", 1);
225 300
226 static const struct { 301 static const struct {
227 const char *name; 302 const char *name;
228 IV iv; 303 IV iv;
229 } *civ, const_iv[] = { 304 } *civ, const_iv[] = {
230# define const_iv(pfx, name) { # name, (IV) pfx ## name }, 305# define const_iv(pfx, name) { # name, (IV) pfx ## name },
306 const_iv (EV_, MINPRI)
307 const_iv (EV_, MAXPRI)
308
231 const_iv (EV_, UNDEF) 309 const_iv (EV_, UNDEF)
232 const_iv (EV_, NONE) 310 const_iv (EV_, NONE)
233 const_iv (EV_, TIMEOUT) 311 const_iv (EV_, TIMEOUT)
234 const_iv (EV_, READ) 312 const_iv (EV_, READ)
235 const_iv (EV_, WRITE) 313 const_iv (EV_, WRITE)
239 const_iv (EV_, ERROR) 317 const_iv (EV_, ERROR)
240 318
241 const_iv (EV, LOOP_ONESHOT) 319 const_iv (EV, LOOP_ONESHOT)
242 const_iv (EV, LOOP_NONBLOCK) 320 const_iv (EV, LOOP_NONBLOCK)
243 321
244 const_iv (EV, METHOD_NONE) 322 const_iv (EV, METHOD_AUTO)
245 const_iv (EV, METHOD_SELECT) 323 const_iv (EV, METHOD_SELECT)
324 const_iv (EV, METHOD_POLL)
246 const_iv (EV, METHOD_EPOLL) 325 const_iv (EV, METHOD_EPOLL)
326 const_iv (EV, METHOD_KQUEUE)
327 const_iv (EV, METHOD_DEVPOLL)
328 const_iv (EV, METHOD_PORT)
329 const_iv (EV, METHOD_ANY)
247 }; 330 };
248 331
249 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 332 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
250 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 333 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
251 334
266 /* the poor man's shared library emulator */ 349 /* the poor man's shared library emulator */
267 evapi.ver = EV_API_VERSION; 350 evapi.ver = EV_API_VERSION;
268 evapi.rev = EV_API_REVISION; 351 evapi.rev = EV_API_REVISION;
269 evapi.sv_fileno = sv_fileno; 352 evapi.sv_fileno = sv_fileno;
270 evapi.sv_signum = sv_signum; 353 evapi.sv_signum = sv_signum;
271 evapi.now = &ev_now; 354 evapi.now = ev_now;
272 evapi.method = &ev_method; 355 evapi.method = ev_method;
273 evapi.loop_done = &ev_loop_done; 356 evapi.unloop = ev_unloop;
274 evapi.time = ev_time; 357 evapi.time = ev_time;
275 evapi.loop = ev_loop; 358 evapi.loop = ev_loop;
276 evapi.once = ev_once; 359 evapi.once = ev_once;
277 evapi.io_start = ev_io_start; 360 evapi.io_start = ev_io_start;
278 evapi.io_stop = ev_io_stop; 361 evapi.io_stop = ev_io_stop;
293 evapi.child_stop = ev_child_stop; 376 evapi.child_stop = ev_child_stop;
294 377
295 sv_setiv (sv, (IV)&evapi); 378 sv_setiv (sv, (IV)&evapi);
296 SvREADONLY_on (sv); 379 SvREADONLY_on (sv);
297 } 380 }
381#ifndef WIN32
382 pthread_atfork (0, 0, ev_default_fork);
383#endif
298} 384}
299 385
300NV ev_now () 386NV ev_now ()
301 CODE:
302 RETVAL = ev_now;
303 OUTPUT:
304 RETVAL
305 387
306int ev_method () 388int ev_method ()
307 CODE:
308 RETVAL = ev_method;
309 OUTPUT:
310 RETVAL
311 389
312NV ev_time () 390NV ev_time ()
313 391
314void ev_init (int flags = 0) 392int ev_default_loop (int methods = EVMETHOD_AUTO)
315 393
316void ev_loop (int flags = 0) 394void ev_loop (int flags = 0)
317 395
318void ev_loop_done (int value = 1) 396void ev_unloop (int how = 1)
319 CODE:
320 ev_loop_done = value;
321 397
322struct ev_io *io (SV *fh, int events, SV *cb) 398struct ev_io *io (SV *fh, int events, SV *cb)
323 ALIAS: 399 ALIAS:
324 io_ns = 1 400 io_ns = 1
325 CODE: 401 CODE:
345 ev_timer_set (RETVAL, after, repeat); 421 ev_timer_set (RETVAL, after, repeat);
346 if (!ix) ev_timer_start (RETVAL); 422 if (!ix) ev_timer_start (RETVAL);
347 OUTPUT: 423 OUTPUT:
348 RETVAL 424 RETVAL
349 425
350struct ev_periodic *periodic (NV at, NV interval, SV *cb) 426SV *periodic (NV at, NV interval, SV *reschedule_cb, SV *cb)
351 ALIAS: 427 ALIAS:
352 periodic_ns = 1 428 periodic_ns = 1
353 INIT: 429 INIT:
354 CHECK_REPEAT (interval); 430 CHECK_REPEAT (interval);
355 CODE: 431 CODE:
432{
433 struct ev_periodic *w;
356 RETVAL = e_new (sizeof (struct ev_periodic), cb); 434 w = e_new (sizeof (struct ev_periodic), cb);
357 ev_periodic_set (RETVAL, at, interval); 435 w->fh = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0;
436 ev_periodic_set (w, at, interval, w->fh ? e_periodic_cb : 0);
437 RETVAL = e_bless ((struct ev_watcher *)w, stash_periodic);
358 if (!ix) ev_periodic_start (RETVAL); 438 if (!ix) ev_periodic_start (w);
439}
359 OUTPUT: 440 OUTPUT:
360 RETVAL 441 RETVAL
361 442
362struct ev_signal *signal (Signal signum, SV *cb) 443struct ev_signal *signal (Signal signum, SV *cb)
363 ALIAS: 444 ALIAS:
401 482
402struct ev_child *child (int pid, SV *cb) 483struct ev_child *child (int pid, SV *cb)
403 ALIAS: 484 ALIAS:
404 check_ns = 1 485 check_ns = 1
405 CODE: 486 CODE:
406 RETVAL = e_new (sizeof (struct ev_check), cb); 487 RETVAL = e_new (sizeof (struct ev_child), cb);
407 ev_child_set (RETVAL, pid); 488 ev_child_set (RETVAL, pid);
408 if (!ix) ev_child_start (RETVAL); 489 if (!ix) ev_child_start (RETVAL);
409 OUTPUT: 490 OUTPUT:
410 RETVAL 491 RETVAL
411 492
425 sv_setsv (w->cb_sv, new_cb); 506 sv_setsv (w->cb_sv, new_cb);
426} 507}
427 OUTPUT: 508 OUTPUT:
428 RETVAL 509 RETVAL
429 510
511SV *data (struct ev_watcher *w, SV *new_data = 0)
512 CODE:
513{
514 RETVAL = w->data ? newSVsv (w->data) : &PL_sv_undef;
515}
516 OUTPUT:
517 RETVAL
518
430void trigger (struct ev_watcher *w, int revents = EV_NONE) 519void trigger (struct ev_watcher *w, int revents = EV_NONE)
431 CODE: 520 CODE:
432 w->cb (w, revents); 521 w->cb (w, revents);
433 522
523int priority (struct ev_watcher *w, int new_priority = 0)
524 CODE:
525{
526 RETVAL = w->priority;
527
528 if (items > 1)
529 {
530 int active = ev_is_active (w);
531
532 if (new_priority < EV_MINPRI || new_priority > EV_MAXPRI)
533 croak ("watcher priority out of range, value must be between %d and %d, inclusive", EV_MINPRI, EV_MAXPRI);
534
535 if (active)
536 {
537 /* grrr. */
538 PUSHMARK (SP);
539 XPUSHs (ST (0));
540 call_method ("stop", G_DISCARD | G_VOID);
541 }
542
543 ev_set_priority (w, new_priority);
544
545 if (active)
546 {
547 PUSHMARK (SP);
548 XPUSHs (ST (0));
549 call_method ("start", G_DISCARD | G_VOID);
550 }
551 }
552}
553 OUTPUT:
554 RETVAL
555
434MODULE = EV PACKAGE = EV::Io PREFIX = ev_io_ 556MODULE = EV PACKAGE = EV::Io PREFIX = ev_io_
435 557
436void ev_io_start (struct ev_io *w) 558void ev_io_start (struct ev_io *w)
437 559
438void ev_io_stop (struct ev_io *w) 560void ev_io_stop (struct ev_io *w)
439 561
440void DESTROY (struct ev_io *w) 562void DESTROY (struct ev_io *w)
441 CODE: 563 CODE:
442 ev_io_stop (w); 564 ev_io_stop (w);
565 e_destroy (w);
443 566
444void set (struct ev_io *w, SV *fh, int events) 567void set (struct ev_io *w, SV *fh, int events)
445 CODE: 568 CODE:
446{ 569{
447 int active = w->active; 570 int active = ev_is_active (w);
448 int fd = sv_fileno (fh); 571 int fd = sv_fileno (fh);
449 CHECK_FD (fh, fd); 572 CHECK_FD (fh, fd);
450 573
451 if (active) ev_io_stop (w); 574 if (active) ev_io_stop (w);
452 575
461{ 584{
462 RETVAL = newSVsv (w->fh); 585 RETVAL = newSVsv (w->fh);
463 586
464 if (items > 1) 587 if (items > 1)
465 { 588 {
466 int active = w->active; 589 int active = ev_is_active (w);
467 if (active) ev_io_stop (w); 590 if (active) ev_io_stop (w);
468 591
469 sv_setsv (w->fh, new_fh); 592 sv_setsv (w->fh, new_fh);
470 ev_io_set (w, sv_fileno (w->fh), w->events); 593 ev_io_set (w, sv_fileno (w->fh), w->events);
471 594
473 } 596 }
474} 597}
475 OUTPUT: 598 OUTPUT:
476 RETVAL 599 RETVAL
477 600
478short events (struct ev_io *w, short new_events = EV_UNDEF) 601int events (struct ev_io *w, int new_events = EV_UNDEF)
479 CODE: 602 CODE:
480{ 603{
481 RETVAL = w->events; 604 RETVAL = w->events;
482 605
483 if (items > 1) 606 if (items > 1)
484 { 607 {
485 int active = w->active; 608 int active = ev_is_active (w);
486 if (active) ev_io_stop (w); 609 if (active) ev_io_stop (w);
487 610
488 ev_io_set (w, w->fd, new_events); 611 ev_io_set (w, w->fd, new_events);
489 612
490 if (active) ev_io_start (w); 613 if (active) ev_io_start (w);
500void ev_signal_stop (struct ev_signal *w) 623void ev_signal_stop (struct ev_signal *w)
501 624
502void DESTROY (struct ev_signal *w) 625void DESTROY (struct ev_signal *w)
503 CODE: 626 CODE:
504 ev_signal_stop (w); 627 ev_signal_stop (w);
628 e_destroy (w);
505 629
506void set (struct ev_signal *w, SV *signal = 0) 630void set (struct ev_signal *w, SV *signal)
507 CODE: 631 CODE:
508{ 632{
509 Signal signum = sv_signum (signal); /* may croak here */ 633 Signal signum = sv_signum (signal); /* may croak here */
510 int active = w->active; 634 int active = ev_is_active (w);
511 635
512 if (active) ev_signal_stop (w); 636 if (active) ev_signal_stop (w);
637
513 ev_signal_set (w, signum); 638 ev_signal_set (w, signum);
639
514 if (active) ev_signal_start (w); 640 if (active) ev_signal_start (w);
515} 641}
516 642
517MODULE = EV PACKAGE = EV::Time 643int signal (struct ev_signal *w, SV *new_signal = 0)
644 CODE:
645{
646 RETVAL = w->signum;
647
648 if (items > 1)
649 {
650 Signal signum = sv_signum (new_signal); /* may croak here */
651 int active = ev_is_active (w);
652 if (active) ev_signal_stop (w);
653
654 ev_signal_set (w, signum);
655
656 if (active) ev_signal_start (w);
657 }
658}
659 OUTPUT:
660 RETVAL
518 661
519MODULE = EV PACKAGE = EV::Timer PREFIX = ev_timer_ 662MODULE = EV PACKAGE = EV::Timer PREFIX = ev_timer_
520 663
521void ev_timer_start (struct ev_timer *w) 664void ev_timer_start (struct ev_timer *w)
522 INIT: 665 INIT:
529 CHECK_REPEAT (w->repeat); 672 CHECK_REPEAT (w->repeat);
530 673
531void DESTROY (struct ev_timer *w) 674void DESTROY (struct ev_timer *w)
532 CODE: 675 CODE:
533 ev_timer_stop (w); 676 ev_timer_stop (w);
677 e_destroy (w);
534 678
535void set (struct ev_timer *w, NV after, NV repeat = 0.) 679void set (struct ev_timer *w, NV after, NV repeat = 0.)
536 INIT: 680 INIT:
537 CHECK_REPEAT (repeat); 681 CHECK_REPEAT (repeat);
538 CODE: 682 CODE:
539{ 683{
540 int active = w->active; 684 int active = ev_is_active (w);
541 if (active) ev_timer_stop (w); 685 if (active) ev_timer_stop (w);
542 ev_timer_set (w, after, repeat); 686 ev_timer_set (w, after, repeat);
543 if (active) ev_timer_start (w); 687 if (active) ev_timer_start (w);
544} 688}
545 689
549 INIT: 693 INIT:
550 CHECK_REPEAT (w->interval); 694 CHECK_REPEAT (w->interval);
551 695
552void ev_periodic_stop (struct ev_periodic *w) 696void ev_periodic_stop (struct ev_periodic *w)
553 697
698void ev_periodic_again (struct ev_periodic *w)
699
554void DESTROY (struct ev_periodic *w) 700void DESTROY (struct ev_periodic *w)
555 CODE: 701 CODE:
556 ev_periodic_stop (w); 702 ev_periodic_stop (w);
703 e_destroy (w);
557 704
558void set (struct ev_periodic *w, NV at, NV interval = 0.) 705void set (struct ev_periodic *w, NV at, NV interval = 0., SV *reschedule_cb = &PL_sv_undef)
559 INIT: 706 INIT:
560 CHECK_REPEAT (interval); 707 CHECK_REPEAT (interval);
561 CODE: 708 CODE:
562{ 709{
563 int active = w->active; 710 int active = ev_is_active (w);
564 if (active) ev_periodic_stop (w); 711 if (active) ev_periodic_stop (w);
712
713 SvREFCNT_dec (w->fh);
714 w->fh = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0;
565 ev_periodic_set (w, at, interval); 715 ev_periodic_set (w, at, interval, w->fh ? e_periodic_cb : 0);
716
566 if (active) ev_periodic_start (w); 717 if (active) ev_periodic_start (w);
567} 718}
568 719
569MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_ 720MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_
570 721
573void ev_idle_stop (struct ev_idle *w) 724void ev_idle_stop (struct ev_idle *w)
574 725
575void DESTROY (struct ev_idle *w) 726void DESTROY (struct ev_idle *w)
576 CODE: 727 CODE:
577 ev_idle_stop (w); 728 ev_idle_stop (w);
729 e_destroy (w);
578 730
579MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_check_ 731MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_check_
580 732
581void ev_prepare_start (struct ev_prepare *w) 733void ev_prepare_start (struct ev_prepare *w)
582 734
583void ev_prepare_stop (struct ev_prepare *w) 735void ev_prepare_stop (struct ev_prepare *w)
584 736
585void DESTROY (struct ev_prepare *w) 737void DESTROY (struct ev_prepare *w)
586 CODE: 738 CODE:
587 ev_prepare_stop (w); 739 ev_prepare_stop (w);
740 e_destroy (w);
588 741
589MODULE = EV PACKAGE = EV::Check PREFIX = ev_check_ 742MODULE = EV PACKAGE = EV::Check PREFIX = ev_check_
590 743
591void ev_check_start (struct ev_check *w) 744void ev_check_start (struct ev_check *w)
592 745
593void ev_check_stop (struct ev_check *w) 746void ev_check_stop (struct ev_check *w)
594 747
595void DESTROY (struct ev_check *w) 748void DESTROY (struct ev_check *w)
596 CODE: 749 CODE:
597 ev_check_stop (w); 750 ev_check_stop (w);
751 e_destroy (w);
598 752
599MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ 753MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_
600 754
601void ev_child_start (struct ev_child *w) 755void ev_child_start (struct ev_child *w)
602 756
603void ev_child_stop (struct ev_child *w) 757void ev_child_stop (struct ev_child *w)
604 758
605void DESTROY (struct ev_child *w) 759void DESTROY (struct ev_child *w)
606 CODE: 760 CODE:
607 ev_child_stop (w); 761 ev_child_stop (w);
762 e_destroy (w);
608 763
609void set (struct ev_child *w, int pid) 764void set (struct ev_child *w, int pid)
610 CODE: 765 CODE:
611{ 766{
612 int active = w->active; 767 int active = ev_is_active (w);
613 if (active) ev_child_stop (w); 768 if (active) ev_child_stop (w);
769
614 ev_child_set (w, pid); 770 ev_child_set (w, pid);
771
615 if (active) ev_child_start (w); 772 if (active) ev_child_start (w);
616} 773}
617 774
775int pid (struct ev_child *w, int new_pid = 0)
776 CODE:
777{
778 RETVAL = w->pid;
779
780 if (items > 1)
781 {
782 int active = ev_is_active (w);
783 if (active) ev_child_stop (w);
784
785 ev_child_set (w, new_pid);
786
787 if (active) ev_child_start (w);
788 }
789}
790 OUTPUT:
791 RETVAL
792
793
618int status (struct ev_child *w) 794int rstatus (struct ev_child *w)
795 ALIAS:
796 rpid = 1
619 CODE: 797 CODE:
620 RETVAL = w->status; 798 RETVAL = ix ? w->rpid : w->rstatus;
621 OUTPUT: 799 OUTPUT:
622 RETVAL 800 RETVAL
623 801
624#if 0 802#ifndef WIN32
625 803
626MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ 804MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_
627 805
628BOOT: 806BOOT:
629{ 807{
712 890
713void evdns_search_add (char *domain) 891void evdns_search_add (char *domain)
714 892
715void evdns_search_ndots_set (int ndots) 893void evdns_search_ndots_set (int ndots)
716 894
895#if 0
717 896
718MODULE = EV PACKAGE = EV::HTTP PREFIX = evhttp_ 897MODULE = EV PACKAGE = EV::HTTP PREFIX = evhttp_
719 898
720BOOT: 899BOOT:
721{ 900{
753 932
754#void DESTROY (struct evhttp_request *req); 933#void DESTROY (struct evhttp_request *req);
755 934
756#endif 935#endif
757 936
937#endif
758 938
759 939
760 940
761 941
762 942

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines