… | |
… | |
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 | |
… | |
… | |
108 | dSP; |
123 | dSP; |
109 | I32 mark = SP - PL_stack_base; |
124 | I32 mark = SP - PL_stack_base; |
110 | SV *sv_self, *sv_events, *sv_status = 0; |
125 | SV *sv_self, *sv_events, *sv_status = 0; |
111 | static SV *sv_events_cache; |
126 | static SV *sv_events_cache; |
112 | |
127 | |
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 */ |
128 | sv_self = newRV_inc (w->self); /* w->self MUST be blessed by now */ |
116 | |
129 | |
117 | if (sv_events_cache) |
130 | if (sv_events_cache) |
118 | { |
131 | { |
119 | sv_events = sv_events_cache; sv_events_cache = 0; |
132 | sv_events = sv_events_cache; sv_events_cache = 0; |
… | |
… | |
149 | 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); |
150 | SP = PL_stack_base + mark; PUTBACK; |
163 | SP = PL_stack_base + mark; PUTBACK; |
151 | } |
164 | } |
152 | } |
165 | } |
153 | |
166 | |
154 | #if 0 |
|
|
155 | ///////////////////////////////////////////////////////////////////////////// |
167 | ///////////////////////////////////////////////////////////////////////////// |
156 | // DNS |
168 | // DNS |
157 | |
169 | |
158 | static void |
170 | static void |
159 | 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) |
… | |
… | |
201 | 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); |
202 | } |
214 | } |
203 | |
215 | |
204 | LEAVE; |
216 | LEAVE; |
205 | } |
217 | } |
206 | #endif |
|
|
207 | |
218 | |
208 | #define CHECK_REPEAT(repeat) if (repeat < 0.) \ |
219 | #define CHECK_REPEAT(repeat) if (repeat < 0.) \ |
209 | croak (# repeat " value must be >= 0"); |
220 | croak (# repeat " value must be >= 0"); |
210 | |
221 | |
211 | #define CHECK_FD(fh,fd) if ((fd) < 0) \ |
222 | #define CHECK_FD(fh,fd) if ((fd) < 0) \ |
… | |
… | |
293 | evapi.child_stop = ev_child_stop; |
304 | evapi.child_stop = ev_child_stop; |
294 | |
305 | |
295 | sv_setiv (sv, (IV)&evapi); |
306 | sv_setiv (sv, (IV)&evapi); |
296 | SvREADONLY_on (sv); |
307 | SvREADONLY_on (sv); |
297 | } |
308 | } |
|
|
309 | |
|
|
310 | pthread_atfork (ev_fork_prepare, ev_fork_parent, ev_fork_child); |
298 | } |
311 | } |
299 | |
312 | |
300 | NV ev_now () |
313 | NV ev_now () |
301 | CODE: |
314 | CODE: |
302 | RETVAL = ev_now; |
315 | RETVAL = ev_now; |
… | |
… | |
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; |
… | |
… | |
473 | } |
487 | } |
474 | } |
488 | } |
475 | OUTPUT: |
489 | OUTPUT: |
476 | RETVAL |
490 | RETVAL |
477 | |
491 | |
478 | short events (struct ev_io *w, short new_events = EV_UNDEF) |
492 | int events (struct ev_io *w, int new_events = EV_UNDEF) |
479 | CODE: |
493 | CODE: |
480 | { |
494 | { |
481 | RETVAL = w->events; |
495 | RETVAL = w->events; |
482 | |
496 | |
483 | if (items > 1) |
497 | if (items > 1) |
… | |
… | |
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 | { |