… | |
… | |
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 |
7 | #define TIMEOUT_NONE HUGE_VAL |
8 | #define EV_USE_EPOLL 1 |
|
|
9 | |
8 | |
10 | #define EV_PROTOTYPES 1 |
9 | #define EV_PROTOTYPES 1 |
11 | #include "EV/EVAPI.h" |
10 | #include "EV/EVAPI.h" |
12 | |
11 | |
13 | #include "libev/ev.c" |
12 | #include "libev/ev.c" |
|
|
13 | #include "libev/event.h" |
|
|
14 | #include "libev/event.c" |
|
|
15 | |
|
|
16 | #define DNS_USE_GETTIMEOFDAY_FOR_ID 1 |
|
|
17 | #define HAVE_STRUCT_IN6_ADDR 1 |
|
|
18 | #define HAVE_STRTOK_R 1 |
|
|
19 | #include "libev/evdns.c" |
14 | |
20 | |
15 | typedef int Signal; |
21 | typedef int Signal; |
16 | |
22 | |
17 | static struct EVAPI evapi; |
23 | static struct EVAPI evapi; |
18 | |
24 | |
… | |
… | |
83 | w->self = self; |
89 | w->self = self; |
84 | |
90 | |
85 | return (void *)w; |
91 | return (void *)w; |
86 | } |
92 | } |
87 | |
93 | |
|
|
94 | static void * |
|
|
95 | e_destroy (void *w_) |
|
|
96 | { |
|
|
97 | struct ev_watcher *w = w_; |
|
|
98 | |
|
|
99 | SvREFCNT_dec (w->fh ); w->fh = 0; |
|
|
100 | SvREFCNT_dec (w->cb_sv); w->cb_sv = 0; |
|
|
101 | } |
|
|
102 | |
88 | static SV * |
103 | static SV * |
89 | e_bless (struct ev_watcher *w, HV *stash) |
104 | e_bless (struct ev_watcher *w, HV *stash) |
90 | { |
105 | { |
91 | SV *rv; |
106 | SV *rv; |
92 | |
107 | |
… | |
… | |
147 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
162 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
148 | SP = PL_stack_base + mark; PUTBACK; |
163 | SP = PL_stack_base + mark; PUTBACK; |
149 | } |
164 | } |
150 | } |
165 | } |
151 | |
166 | |
152 | #if 0 |
|
|
153 | ///////////////////////////////////////////////////////////////////////////// |
167 | ///////////////////////////////////////////////////////////////////////////// |
154 | // DNS |
168 | // DNS |
155 | |
169 | |
156 | static void |
170 | static void |
157 | dns_cb (int result, char type, int count, int ttl, void *addresses, void *arg) |
171 | dns_cb (int result, char type, int count, int ttl, void *addresses, void *arg) |
… | |
… | |
199 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
213 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
200 | } |
214 | } |
201 | |
215 | |
202 | LEAVE; |
216 | LEAVE; |
203 | } |
217 | } |
204 | #endif |
|
|
205 | |
218 | |
206 | #define CHECK_REPEAT(repeat) if (repeat < 0.) \ |
219 | #define CHECK_REPEAT(repeat) if (repeat < 0.) \ |
207 | croak (# repeat " value must be >= 0"); |
220 | croak (# repeat " value must be >= 0"); |
208 | |
221 | |
209 | #define CHECK_FD(fh,fd) if ((fd) < 0) \ |
222 | #define CHECK_FD(fh,fd) if ((fd) < 0) \ |
… | |
… | |
291 | evapi.child_stop = ev_child_stop; |
304 | evapi.child_stop = ev_child_stop; |
292 | |
305 | |
293 | sv_setiv (sv, (IV)&evapi); |
306 | sv_setiv (sv, (IV)&evapi); |
294 | SvREADONLY_on (sv); |
307 | SvREADONLY_on (sv); |
295 | } |
308 | } |
|
|
309 | |
|
|
310 | pthread_atfork (ev_fork_prepare, ev_fork_parent, ev_fork_child); |
296 | } |
311 | } |
297 | |
312 | |
298 | NV ev_now () |
313 | NV ev_now () |
299 | CODE: |
314 | CODE: |
300 | RETVAL = ev_now; |
315 | RETVAL = ev_now; |
… | |
… | |
436 | void ev_io_stop (struct ev_io *w) |
451 | void ev_io_stop (struct ev_io *w) |
437 | |
452 | |
438 | void DESTROY (struct ev_io *w) |
453 | void DESTROY (struct ev_io *w) |
439 | CODE: |
454 | CODE: |
440 | ev_io_stop (w); |
455 | ev_io_stop (w); |
|
|
456 | e_destroy (w); |
441 | |
457 | |
442 | void set (struct ev_io *w, SV *fh, int events) |
458 | void set (struct ev_io *w, SV *fh, int events) |
443 | CODE: |
459 | CODE: |
444 | { |
460 | { |
445 | int active = w->active; |
461 | int active = w->active; |
… | |
… | |
471 | } |
487 | } |
472 | } |
488 | } |
473 | OUTPUT: |
489 | OUTPUT: |
474 | RETVAL |
490 | RETVAL |
475 | |
491 | |
476 | short events (struct ev_io *w, short new_events = EV_UNDEF) |
492 | int events (struct ev_io *w, int new_events = EV_UNDEF) |
477 | CODE: |
493 | CODE: |
478 | { |
494 | { |
479 | RETVAL = w->events; |
495 | RETVAL = w->events; |
480 | |
496 | |
481 | if (items > 1) |
497 | if (items > 1) |
… | |
… | |
498 | void ev_signal_stop (struct ev_signal *w) |
514 | void ev_signal_stop (struct ev_signal *w) |
499 | |
515 | |
500 | void DESTROY (struct ev_signal *w) |
516 | void DESTROY (struct ev_signal *w) |
501 | CODE: |
517 | CODE: |
502 | ev_signal_stop (w); |
518 | ev_signal_stop (w); |
|
|
519 | e_destroy (w); |
503 | |
520 | |
504 | void set (struct ev_signal *w, SV *signal = 0) |
521 | void set (struct ev_signal *w, SV *signal = 0) |
505 | CODE: |
522 | CODE: |
506 | { |
523 | { |
507 | Signal signum = sv_signum (signal); /* may croak here */ |
524 | Signal signum = sv_signum (signal); /* may croak here */ |
… | |
… | |
527 | CHECK_REPEAT (w->repeat); |
544 | CHECK_REPEAT (w->repeat); |
528 | |
545 | |
529 | void DESTROY (struct ev_timer *w) |
546 | void DESTROY (struct ev_timer *w) |
530 | CODE: |
547 | CODE: |
531 | ev_timer_stop (w); |
548 | ev_timer_stop (w); |
|
|
549 | e_destroy (w); |
532 | |
550 | |
533 | void set (struct ev_timer *w, NV after, NV repeat = 0.) |
551 | void set (struct ev_timer *w, NV after, NV repeat = 0.) |
534 | INIT: |
552 | INIT: |
535 | CHECK_REPEAT (repeat); |
553 | CHECK_REPEAT (repeat); |
536 | CODE: |
554 | CODE: |
… | |
… | |
550 | void ev_periodic_stop (struct ev_periodic *w) |
568 | void ev_periodic_stop (struct ev_periodic *w) |
551 | |
569 | |
552 | void DESTROY (struct ev_periodic *w) |
570 | void DESTROY (struct ev_periodic *w) |
553 | CODE: |
571 | CODE: |
554 | ev_periodic_stop (w); |
572 | ev_periodic_stop (w); |
|
|
573 | e_destroy (w); |
555 | |
574 | |
556 | void set (struct ev_periodic *w, NV at, NV interval = 0.) |
575 | void set (struct ev_periodic *w, NV at, NV interval = 0.) |
557 | INIT: |
576 | INIT: |
558 | CHECK_REPEAT (interval); |
577 | CHECK_REPEAT (interval); |
559 | CODE: |
578 | CODE: |
… | |
… | |
571 | void ev_idle_stop (struct ev_idle *w) |
590 | void ev_idle_stop (struct ev_idle *w) |
572 | |
591 | |
573 | void DESTROY (struct ev_idle *w) |
592 | void DESTROY (struct ev_idle *w) |
574 | CODE: |
593 | CODE: |
575 | ev_idle_stop (w); |
594 | ev_idle_stop (w); |
|
|
595 | e_destroy (w); |
576 | |
596 | |
577 | MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_check_ |
597 | MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_check_ |
578 | |
598 | |
579 | void ev_prepare_start (struct ev_prepare *w) |
599 | void ev_prepare_start (struct ev_prepare *w) |
580 | |
600 | |
581 | void ev_prepare_stop (struct ev_prepare *w) |
601 | void ev_prepare_stop (struct ev_prepare *w) |
582 | |
602 | |
583 | void DESTROY (struct ev_prepare *w) |
603 | void DESTROY (struct ev_prepare *w) |
584 | CODE: |
604 | CODE: |
585 | ev_prepare_stop (w); |
605 | ev_prepare_stop (w); |
|
|
606 | e_destroy (w); |
586 | |
607 | |
587 | MODULE = EV PACKAGE = EV::Check PREFIX = ev_check_ |
608 | MODULE = EV PACKAGE = EV::Check PREFIX = ev_check_ |
588 | |
609 | |
589 | void ev_check_start (struct ev_check *w) |
610 | void ev_check_start (struct ev_check *w) |
590 | |
611 | |
591 | void ev_check_stop (struct ev_check *w) |
612 | void ev_check_stop (struct ev_check *w) |
592 | |
613 | |
593 | void DESTROY (struct ev_check *w) |
614 | void DESTROY (struct ev_check *w) |
594 | CODE: |
615 | CODE: |
595 | ev_check_stop (w); |
616 | ev_check_stop (w); |
|
|
617 | e_destroy (w); |
596 | |
618 | |
597 | MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ |
619 | MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ |
598 | |
620 | |
599 | void ev_child_start (struct ev_child *w) |
621 | void ev_child_start (struct ev_child *w) |
600 | |
622 | |
601 | void ev_child_stop (struct ev_child *w) |
623 | void ev_child_stop (struct ev_child *w) |
602 | |
624 | |
603 | void DESTROY (struct ev_child *w) |
625 | void DESTROY (struct ev_child *w) |
604 | CODE: |
626 | CODE: |
605 | ev_child_stop (w); |
627 | ev_child_stop (w); |
|
|
628 | e_destroy (w); |
606 | |
629 | |
607 | void set (struct ev_child *w, int pid) |
630 | void set (struct ev_child *w, int pid) |
608 | CODE: |
631 | CODE: |
609 | { |
632 | { |
610 | int active = w->active; |
633 | int active = w->active; |
… | |
… | |
616 | int status (struct ev_child *w) |
639 | int status (struct ev_child *w) |
617 | CODE: |
640 | CODE: |
618 | RETVAL = w->status; |
641 | RETVAL = w->status; |
619 | OUTPUT: |
642 | OUTPUT: |
620 | RETVAL |
643 | RETVAL |
621 | |
|
|
622 | #if 0 |
|
|
623 | |
644 | |
624 | MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ |
645 | MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ |
625 | |
646 | |
626 | BOOT: |
647 | BOOT: |
627 | { |
648 | { |
… | |
… | |
710 | |
731 | |
711 | void evdns_search_add (char *domain) |
732 | void evdns_search_add (char *domain) |
712 | |
733 | |
713 | void evdns_search_ndots_set (int ndots) |
734 | void evdns_search_ndots_set (int ndots) |
714 | |
735 | |
|
|
736 | #if 0 |
715 | |
737 | |
716 | MODULE = EV PACKAGE = EV::HTTP PREFIX = evhttp_ |
738 | MODULE = EV PACKAGE = EV::HTTP PREFIX = evhttp_ |
717 | |
739 | |
718 | BOOT: |
740 | BOOT: |
719 | { |
741 | { |