… | |
… | |
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) \ |
… | |
… | |
438 | void ev_io_stop (struct ev_io *w) |
451 | void ev_io_stop (struct ev_io *w) |
439 | |
452 | |
440 | void DESTROY (struct ev_io *w) |
453 | void DESTROY (struct ev_io *w) |
441 | CODE: |
454 | CODE: |
442 | ev_io_stop (w); |
455 | ev_io_stop (w); |
|
|
456 | e_destroy (w); |
443 | |
457 | |
444 | void set (struct ev_io *w, SV *fh, int events) |
458 | void set (struct ev_io *w, SV *fh, int events) |
445 | CODE: |
459 | CODE: |
446 | { |
460 | { |
447 | int active = w->active; |
461 | int active = w->active; |
… | |
… | |
500 | void ev_signal_stop (struct ev_signal *w) |
514 | void ev_signal_stop (struct ev_signal *w) |
501 | |
515 | |
502 | void DESTROY (struct ev_signal *w) |
516 | void DESTROY (struct ev_signal *w) |
503 | CODE: |
517 | CODE: |
504 | ev_signal_stop (w); |
518 | ev_signal_stop (w); |
|
|
519 | e_destroy (w); |
505 | |
520 | |
506 | void set (struct ev_signal *w, SV *signal = 0) |
521 | void set (struct ev_signal *w, SV *signal = 0) |
507 | CODE: |
522 | CODE: |
508 | { |
523 | { |
509 | Signal signum = sv_signum (signal); /* may croak here */ |
524 | Signal signum = sv_signum (signal); /* may croak here */ |
… | |
… | |
529 | CHECK_REPEAT (w->repeat); |
544 | CHECK_REPEAT (w->repeat); |
530 | |
545 | |
531 | void DESTROY (struct ev_timer *w) |
546 | void DESTROY (struct ev_timer *w) |
532 | CODE: |
547 | CODE: |
533 | ev_timer_stop (w); |
548 | ev_timer_stop (w); |
|
|
549 | e_destroy (w); |
534 | |
550 | |
535 | void set (struct ev_timer *w, NV after, NV repeat = 0.) |
551 | void set (struct ev_timer *w, NV after, NV repeat = 0.) |
536 | INIT: |
552 | INIT: |
537 | CHECK_REPEAT (repeat); |
553 | CHECK_REPEAT (repeat); |
538 | CODE: |
554 | CODE: |
… | |
… | |
552 | void ev_periodic_stop (struct ev_periodic *w) |
568 | void ev_periodic_stop (struct ev_periodic *w) |
553 | |
569 | |
554 | void DESTROY (struct ev_periodic *w) |
570 | void DESTROY (struct ev_periodic *w) |
555 | CODE: |
571 | CODE: |
556 | ev_periodic_stop (w); |
572 | ev_periodic_stop (w); |
|
|
573 | e_destroy (w); |
557 | |
574 | |
558 | void set (struct ev_periodic *w, NV at, NV interval = 0.) |
575 | void set (struct ev_periodic *w, NV at, NV interval = 0.) |
559 | INIT: |
576 | INIT: |
560 | CHECK_REPEAT (interval); |
577 | CHECK_REPEAT (interval); |
561 | CODE: |
578 | CODE: |
… | |
… | |
573 | void ev_idle_stop (struct ev_idle *w) |
590 | void ev_idle_stop (struct ev_idle *w) |
574 | |
591 | |
575 | void DESTROY (struct ev_idle *w) |
592 | void DESTROY (struct ev_idle *w) |
576 | CODE: |
593 | CODE: |
577 | ev_idle_stop (w); |
594 | ev_idle_stop (w); |
|
|
595 | e_destroy (w); |
578 | |
596 | |
579 | MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_check_ |
597 | MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_check_ |
580 | |
598 | |
581 | void ev_prepare_start (struct ev_prepare *w) |
599 | void ev_prepare_start (struct ev_prepare *w) |
582 | |
600 | |
583 | void ev_prepare_stop (struct ev_prepare *w) |
601 | void ev_prepare_stop (struct ev_prepare *w) |
584 | |
602 | |
585 | void DESTROY (struct ev_prepare *w) |
603 | void DESTROY (struct ev_prepare *w) |
586 | CODE: |
604 | CODE: |
587 | ev_prepare_stop (w); |
605 | ev_prepare_stop (w); |
|
|
606 | e_destroy (w); |
588 | |
607 | |
589 | MODULE = EV PACKAGE = EV::Check PREFIX = ev_check_ |
608 | MODULE = EV PACKAGE = EV::Check PREFIX = ev_check_ |
590 | |
609 | |
591 | void ev_check_start (struct ev_check *w) |
610 | void ev_check_start (struct ev_check *w) |
592 | |
611 | |
593 | void ev_check_stop (struct ev_check *w) |
612 | void ev_check_stop (struct ev_check *w) |
594 | |
613 | |
595 | void DESTROY (struct ev_check *w) |
614 | void DESTROY (struct ev_check *w) |
596 | CODE: |
615 | CODE: |
597 | ev_check_stop (w); |
616 | ev_check_stop (w); |
|
|
617 | e_destroy (w); |
598 | |
618 | |
599 | MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ |
619 | MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ |
600 | |
620 | |
601 | void ev_child_start (struct ev_child *w) |
621 | void ev_child_start (struct ev_child *w) |
602 | |
622 | |
603 | void ev_child_stop (struct ev_child *w) |
623 | void ev_child_stop (struct ev_child *w) |
604 | |
624 | |
605 | void DESTROY (struct ev_child *w) |
625 | void DESTROY (struct ev_child *w) |
606 | CODE: |
626 | CODE: |
607 | ev_child_stop (w); |
627 | ev_child_stop (w); |
|
|
628 | e_destroy (w); |
608 | |
629 | |
609 | void set (struct ev_child *w, int pid) |
630 | void set (struct ev_child *w, int pid) |
610 | CODE: |
631 | CODE: |
611 | { |
632 | { |
612 | int active = w->active; |
633 | int active = w->active; |
… | |
… | |
618 | int status (struct ev_child *w) |
639 | int status (struct ev_child *w) |
619 | CODE: |
640 | CODE: |
620 | RETVAL = w->status; |
641 | RETVAL = w->status; |
621 | OUTPUT: |
642 | OUTPUT: |
622 | RETVAL |
643 | RETVAL |
623 | |
|
|
624 | #if 0 |
|
|
625 | |
644 | |
626 | MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ |
645 | MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ |
627 | |
646 | |
628 | BOOT: |
647 | BOOT: |
629 | { |
648 | { |
… | |
… | |
712 | |
731 | |
713 | void evdns_search_add (char *domain) |
732 | void evdns_search_add (char *domain) |
714 | |
733 | |
715 | void evdns_search_ndots_set (int ndots) |
734 | void evdns_search_ndots_set (int ndots) |
716 | |
735 | |
|
|
736 | #if 0 |
717 | |
737 | |
718 | MODULE = EV PACKAGE = EV::HTTP PREFIX = evhttp_ |
738 | MODULE = EV PACKAGE = EV::HTTP PREFIX = evhttp_ |
719 | |
739 | |
720 | BOOT: |
740 | BOOT: |
721 | { |
741 | { |