… | |
… | |
9 | |
9 | |
10 | /* fix perl api breakage */ |
10 | /* fix perl api breakage */ |
11 | #undef signal |
11 | #undef signal |
12 | #undef sigaction |
12 | #undef sigaction |
13 | |
13 | |
14 | #define EV_SELECT_USE_WIN32_HANDLES 0 |
14 | #define EV_SELECT_IS_WINSOCKET 0 |
|
|
15 | #ifdef _WIN32 |
15 | #define EV_SELECT_USE_FD_SET 0 |
16 | # define EV_SELECT_USE_FD_SET 0 |
|
|
17 | # define NFDBITS PERL_NFDBITS |
|
|
18 | # define fd_mask Perl_fd_mask |
|
|
19 | #endif |
16 | /* due to bugs in OS X we have to use libev/ explicitly here */ |
20 | /* due to bugs in OS X we have to use libev/ explicitly here */ |
17 | #include "libev/ev.c" |
21 | #include "libev/ev.c" |
18 | #include "event.c" |
22 | #include "event.c" |
19 | |
23 | |
20 | #ifndef WIN32 |
24 | #ifndef _WIN32 |
21 | #define DNS_USE_GETTIMEOFDAY_FOR_ID 1 |
25 | #define DNS_USE_GETTIMEOFDAY_FOR_ID 1 |
22 | #if !defined (WIN32) && !defined(__CYGWIN__) |
26 | #if !defined (WIN32) && !defined(__CYGWIN__) |
23 | # define HAVE_STRUCT_IN6_ADDR 1 |
27 | # define HAVE_STRUCT_IN6_ADDR 1 |
24 | #endif |
28 | #endif |
25 | #undef HAVE_STRTOK_R |
29 | #undef HAVE_STRTOK_R |
26 | #undef strtok_r |
30 | #undef strtok_r |
27 | #define strtok_r fake_strtok_r |
31 | #define strtok_r fake_strtok_r |
|
|
32 | #include "evdns.h" |
28 | #include "evdns.c" |
33 | #include "evdns.c" |
29 | #endif |
34 | #endif |
30 | |
35 | |
31 | #ifndef WIN32 |
36 | #ifndef _WIN32 |
32 | # include <pthread.h> |
37 | # include <pthread.h> |
33 | #endif |
38 | #endif |
34 | |
39 | |
35 | typedef int Signal; |
40 | typedef int Signal; |
36 | |
41 | |
… | |
… | |
100 | SvPOK_only (self); |
105 | SvPOK_only (self); |
101 | SvCUR_set (self, size); |
106 | SvCUR_set (self, size); |
102 | |
107 | |
103 | w = (struct ev_watcher *)SvPVX (self); |
108 | w = (struct ev_watcher *)SvPVX (self); |
104 | |
109 | |
105 | ev_watcher_init (w, e_cb); |
110 | ev_init (w, e_cb); |
106 | |
111 | |
|
|
112 | w->data = 0; |
107 | w->fh = 0; |
113 | w->fh = 0; |
108 | w->cb_sv = newSVsv (cb_sv); |
114 | w->cb_sv = newSVsv (cb_sv); |
109 | w->self = self; |
115 | w->self = self; |
110 | |
116 | |
111 | return (void *)w; |
117 | return (void *)w; |
… | |
… | |
116 | { |
122 | { |
117 | struct ev_watcher *w = (struct ev_watcher *)w_; |
123 | struct ev_watcher *w = (struct ev_watcher *)w_; |
118 | |
124 | |
119 | SvREFCNT_dec (w->fh ); w->fh = 0; |
125 | SvREFCNT_dec (w->fh ); w->fh = 0; |
120 | SvREFCNT_dec (w->cb_sv); w->cb_sv = 0; |
126 | SvREFCNT_dec (w->cb_sv); w->cb_sv = 0; |
|
|
127 | SvREFCNT_dec (w->data ); w->data = 0; |
121 | } |
128 | } |
122 | |
129 | |
123 | static SV * |
130 | static SV * |
124 | e_bless (struct ev_watcher *w, HV *stash) |
131 | e_bless (struct ev_watcher *w, HV *stash) |
125 | { |
132 | { |
… | |
… | |
160 | PUSHs (sv_self); |
167 | PUSHs (sv_self); |
161 | PUSHs (sv_events); |
168 | PUSHs (sv_events); |
162 | |
169 | |
163 | PUTBACK; |
170 | PUTBACK; |
164 | call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); |
171 | call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); |
165 | SP = PL_stack_base + mark; PUTBACK; |
|
|
166 | |
172 | |
167 | SvREFCNT_dec (sv_self); |
173 | SvREFCNT_dec (sv_self); |
168 | SvREFCNT_dec (sv_status); |
174 | SvREFCNT_dec (sv_status); |
169 | |
175 | |
170 | if (sv_events_cache) |
176 | if (sv_events_cache) |
… | |
… | |
175 | if (SvTRUE (ERRSV)) |
181 | if (SvTRUE (ERRSV)) |
176 | { |
182 | { |
177 | PUSHMARK (SP); |
183 | PUSHMARK (SP); |
178 | PUTBACK; |
184 | PUTBACK; |
179 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
185 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
180 | SP = PL_stack_base + mark; PUTBACK; |
|
|
181 | } |
186 | } |
|
|
187 | |
|
|
188 | SP = PL_stack_base + mark; |
|
|
189 | PUTBACK; |
182 | } |
190 | } |
183 | |
191 | |
184 | static ev_tstamp |
192 | static ev_tstamp |
185 | e_periodic_cb (struct ev_periodic *w, ev_tstamp now) |
193 | e_periodic_cb (struct ev_periodic *w, ev_tstamp now) |
186 | { |
194 | { |
… | |
… | |
225 | } |
233 | } |
226 | |
234 | |
227 | ///////////////////////////////////////////////////////////////////////////// |
235 | ///////////////////////////////////////////////////////////////////////////// |
228 | // DNS |
236 | // DNS |
229 | |
237 | |
230 | #ifndef WIN32 |
238 | #ifndef _WIN32 |
231 | static void |
239 | static void |
232 | dns_cb (int result, char type, int count, int ttl, void *addresses, void *arg) |
240 | dns_cb (int result, char type, int count, int ttl, void *addresses, void *arg) |
233 | { |
241 | { |
234 | dSP; |
242 | dSP; |
235 | SV *cb = (SV *)arg; |
243 | SV *cb = (SV *)arg; |
… | |
… | |
313 | const_iv (EV_, CHECK) |
321 | const_iv (EV_, CHECK) |
314 | const_iv (EV_, ERROR) |
322 | const_iv (EV_, ERROR) |
315 | |
323 | |
316 | const_iv (EV, LOOP_ONESHOT) |
324 | const_iv (EV, LOOP_ONESHOT) |
317 | const_iv (EV, LOOP_NONBLOCK) |
325 | const_iv (EV, LOOP_NONBLOCK) |
|
|
326 | const_iv (EV, UNLOOP_ONE) |
|
|
327 | const_iv (EV, UNLOOP_ALL) |
318 | |
328 | |
319 | const_iv (EV, METHOD_AUTO) |
|
|
320 | const_iv (EV, METHOD_SELECT) |
329 | const_iv (EV, METHOD_SELECT) |
321 | const_iv (EV, METHOD_POLL) |
330 | const_iv (EV, METHOD_POLL) |
322 | const_iv (EV, METHOD_EPOLL) |
331 | const_iv (EV, METHOD_EPOLL) |
323 | const_iv (EV, METHOD_KQUEUE) |
332 | const_iv (EV, METHOD_KQUEUE) |
324 | const_iv (EV, METHOD_DEVPOLL) |
333 | const_iv (EV, METHOD_DEVPOLL) |
325 | const_iv (EV, METHOD_PORT) |
334 | const_iv (EV, METHOD_PORT) |
326 | const_iv (EV, METHOD_ANY) |
335 | const_iv (EV, FLAG_AUTO) |
|
|
336 | const_iv (EV, FLAG_NOENV) |
327 | }; |
337 | }; |
328 | |
338 | |
329 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
339 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
330 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
340 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
331 | |
341 | |
… | |
… | |
373 | evapi.child_stop = ev_child_stop; |
383 | evapi.child_stop = ev_child_stop; |
374 | |
384 | |
375 | sv_setiv (sv, (IV)&evapi); |
385 | sv_setiv (sv, (IV)&evapi); |
376 | SvREADONLY_on (sv); |
386 | SvREADONLY_on (sv); |
377 | } |
387 | } |
378 | #ifndef WIN32 |
388 | #ifndef _WIN32 |
379 | pthread_atfork (0, 0, ev_default_fork); |
389 | pthread_atfork (0, 0, ev_default_fork); |
380 | #endif |
390 | #endif |
381 | } |
391 | } |
382 | |
392 | |
383 | NV ev_now () |
393 | NV ev_now () |
384 | |
394 | |
385 | int ev_method () |
395 | int ev_method () |
386 | |
396 | |
387 | NV ev_time () |
397 | NV ev_time () |
388 | |
398 | |
389 | int ev_default_loop (int methods = EVMETHOD_AUTO) |
399 | int ev_default_loop (int methods = EVFLAG_AUTO) |
390 | |
400 | |
391 | void ev_loop (int flags = 0) |
401 | void ev_loop (int flags = 0) |
392 | |
402 | |
393 | void ev_unloop (int how = 1) |
403 | void ev_unloop (int how = 1) |
394 | |
404 | |
… | |
… | |
427 | CHECK_REPEAT (interval); |
437 | CHECK_REPEAT (interval); |
428 | CODE: |
438 | CODE: |
429 | { |
439 | { |
430 | struct ev_periodic *w; |
440 | struct ev_periodic *w; |
431 | w = e_new (sizeof (struct ev_periodic), cb); |
441 | w = e_new (sizeof (struct ev_periodic), cb); |
432 | w->fh = SvOK (reschedule_cb) ? newSVsv (reschedule_cb) : 0; |
442 | w->fh = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; |
433 | ev_periodic_set (w, at, interval, w->fh ? e_periodic_cb : 0); |
443 | ev_periodic_set (w, at, interval, w->fh ? e_periodic_cb : 0); |
434 | RETVAL = e_bless ((struct ev_watcher *)w, stash_periodic); |
444 | RETVAL = e_bless ((struct ev_watcher *)w, stash_periodic); |
435 | if (!ix) ev_periodic_start (w); |
445 | if (!ix) ev_periodic_start (w); |
436 | } |
446 | } |
437 | OUTPUT: |
447 | OUTPUT: |
… | |
… | |
477 | OUTPUT: |
487 | OUTPUT: |
478 | RETVAL |
488 | RETVAL |
479 | |
489 | |
480 | struct ev_child *child (int pid, SV *cb) |
490 | struct ev_child *child (int pid, SV *cb) |
481 | ALIAS: |
491 | ALIAS: |
482 | check_ns = 1 |
492 | child_ns = 1 |
483 | CODE: |
493 | CODE: |
484 | RETVAL = e_new (sizeof (struct ev_child), cb); |
494 | RETVAL = e_new (sizeof (struct ev_child), cb); |
485 | ev_child_set (RETVAL, pid); |
495 | ev_child_set (RETVAL, pid); |
486 | if (!ix) ev_child_start (RETVAL); |
496 | if (!ix) ev_child_start (RETVAL); |
487 | OUTPUT: |
497 | OUTPUT: |
… | |
… | |
499 | { |
509 | { |
500 | RETVAL = newSVsv (w->cb_sv); |
510 | RETVAL = newSVsv (w->cb_sv); |
501 | |
511 | |
502 | if (items > 1) |
512 | if (items > 1) |
503 | sv_setsv (w->cb_sv, new_cb); |
513 | sv_setsv (w->cb_sv, new_cb); |
|
|
514 | } |
|
|
515 | OUTPUT: |
|
|
516 | RETVAL |
|
|
517 | |
|
|
518 | SV *data (struct ev_watcher *w, SV *new_data = 0) |
|
|
519 | CODE: |
|
|
520 | { |
|
|
521 | RETVAL = w->data ? newSVsv (w->data) : &PL_sv_undef; |
504 | } |
522 | } |
505 | OUTPUT: |
523 | OUTPUT: |
506 | RETVAL |
524 | RETVAL |
507 | |
525 | |
508 | void trigger (struct ev_watcher *w, int revents = EV_NONE) |
526 | void trigger (struct ev_watcher *w, int revents = EV_NONE) |
… | |
… | |
786 | CODE: |
804 | CODE: |
787 | RETVAL = ix ? w->rpid : w->rstatus; |
805 | RETVAL = ix ? w->rpid : w->rstatus; |
788 | OUTPUT: |
806 | OUTPUT: |
789 | RETVAL |
807 | RETVAL |
790 | |
808 | |
791 | #ifndef WIN32 |
809 | #ifndef _WIN32 |
792 | |
810 | |
793 | MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ |
811 | MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ |
794 | |
812 | |
795 | BOOT: |
813 | BOOT: |
796 | { |
814 | { |
… | |
… | |
867 | |
885 | |
868 | int evdns_set_option (char *option, char *val, int flags) |
886 | int evdns_set_option (char *option, char *val, int flags) |
869 | |
887 | |
870 | int evdns_resolv_conf_parse (int flags, const char *filename) |
888 | int evdns_resolv_conf_parse (int flags, const char *filename) |
871 | |
889 | |
872 | #ifdef MS_WINDOWS |
890 | #ifdef _WIN32 |
873 | |
891 | |
874 | int evdns_config_windows_nameservers () |
892 | int evdns_config_windows_nameservers () |
875 | |
893 | |
876 | #endif |
894 | #endif |
877 | |
895 | |