… | |
… | |
3 | #include <errno.h> |
3 | #include <errno.h> |
4 | |
4 | |
5 | #include "EXTERN.h" |
5 | #include "EXTERN.h" |
6 | #include "perl.h" |
6 | #include "perl.h" |
7 | #include "XSUB.h" |
7 | #include "XSUB.h" |
|
|
8 | |
|
|
9 | #include "schmorp.h" |
8 | |
10 | |
9 | #include <stddef.h> |
11 | #include <stddef.h> |
10 | #include <stdlib.h> |
12 | #include <stdlib.h> |
11 | #include <errno.h> |
13 | #include <errno.h> |
12 | #include <sys/types.h> |
14 | #include <sys/types.h> |
… | |
… | |
97 | #define expect_false(expr) expect ((expr) != 0, 0) |
99 | #define expect_false(expr) expect ((expr) != 0, 0) |
98 | #define expect_true(expr) expect ((expr) != 0, 1) |
100 | #define expect_true(expr) expect ((expr) != 0, 1) |
99 | |
101 | |
100 | /*****************************************************************************/ |
102 | /*****************************************************************************/ |
101 | |
103 | |
102 | static HV *stash; |
|
|
103 | typedef SV SV8; /* byte-sv, used for argument-checking */ |
104 | typedef SV SV8; /* byte-sv, used for argument-checking */ |
104 | typedef int aio_rfd; /* read file desriptor */ |
105 | typedef int aio_rfd; /* read file desriptor */ |
105 | typedef int aio_wfd; /* write file descriptor */ |
106 | typedef int aio_wfd; /* write file descriptor */ |
106 | |
107 | |
107 | #define AIO_REQ_KLASS "IO::AIO::REQ" |
108 | static HV *aio_stash, *aio_req_stash, *aio_grp_stash; |
108 | #define AIO_GRP_KLASS "IO::AIO::GRP" |
|
|
109 | |
109 | |
110 | #define EIO_REQ_MEMBERS \ |
110 | #define EIO_REQ_MEMBERS \ |
111 | SV *callback; \ |
111 | SV *callback; \ |
112 | SV *sv1, *sv2; \ |
112 | SV *sv1, *sv2; \ |
113 | STRLEN stroffset; \ |
113 | STRLEN stroffset; \ |
… | |
… | |
117 | |
117 | |
118 | #include "libeio/eio.h" |
118 | #include "libeio/eio.h" |
119 | |
119 | |
120 | #ifndef POSIX_FADV_NORMAL |
120 | #ifndef POSIX_FADV_NORMAL |
121 | # define POSIX_FADV_NORMAL 0 |
121 | # define POSIX_FADV_NORMAL 0 |
|
|
122 | # define NO_FADVISE 1 |
122 | #endif |
123 | #endif |
123 | |
124 | |
124 | #ifndef POSIX_FADV_SEQUENTIAL |
125 | #ifndef POSIX_FADV_SEQUENTIAL |
125 | # define POSIX_FADV_SEQUENTIAL 0 |
126 | # define POSIX_FADV_SEQUENTIAL 0 |
126 | #endif |
127 | #endif |
… | |
… | |
157 | |
158 | |
158 | static SV *on_next_submit; |
159 | static SV *on_next_submit; |
159 | static int next_pri = EIO_PRI_DEFAULT; |
160 | static int next_pri = EIO_PRI_DEFAULT; |
160 | static int max_outstanding; |
161 | static int max_outstanding; |
161 | |
162 | |
162 | static int respipe_osf [2], respipe [2] = { -1, -1 }; |
163 | static s_epipe respipe; |
163 | |
164 | |
164 | static void req_destroy (aio_req req); |
165 | static void req_destroy (aio_req req); |
165 | static void req_cancel (aio_req req); |
166 | static void req_cancel (aio_req req); |
166 | |
167 | |
167 | static void want_poll (void) |
168 | static void want_poll (void) |
168 | { |
169 | { |
169 | /* write a dummy byte to the pipe so fh becomes ready */ |
170 | /* write a dummy byte to the pipe so fh becomes ready */ |
170 | respipe_write (respipe_osf [1], (const void *)&respipe_osf, 1); |
171 | s_epipe_signal (&respipe); |
171 | } |
172 | } |
172 | |
173 | |
173 | static void done_poll (void) |
174 | static void done_poll (void) |
174 | { |
175 | { |
175 | /* read any signals sent by the worker threads */ |
176 | /* read any signals sent by the worker threads */ |
176 | char buf [4]; |
177 | s_epipe_drain (&respipe); |
177 | while (respipe_read (respipe [0], buf, 4) == 4) |
|
|
178 | ; |
|
|
179 | } |
178 | } |
180 | |
179 | |
181 | /* must be called at most once */ |
180 | /* must be called at most once */ |
182 | static SV *req_sv (aio_req req, const char *klass) |
181 | static SV *req_sv (aio_req req, HV *stash) |
183 | { |
182 | { |
184 | if (!req->self) |
183 | if (!req->self) |
185 | { |
184 | { |
186 | req->self = (SV *)newHV (); |
185 | req->self = (SV *)newHV (); |
187 | sv_magic (req->self, 0, PERL_MAGIC_ext, (char *)req, 0); |
186 | sv_magic (req->self, 0, PERL_MAGIC_ext, (char *)req, 0); |
188 | } |
187 | } |
189 | |
188 | |
190 | return sv_2mortal (sv_bless (newRV_inc (req->self), gv_stashpv (klass, 1))); |
189 | return sv_2mortal (sv_bless (newRV_inc (req->self), stash)); |
191 | } |
190 | } |
192 | |
191 | |
193 | static aio_req SvAIO_REQ (SV *sv) |
192 | static aio_req SvAIO_REQ (SV *sv) |
194 | { |
193 | { |
195 | MAGIC *mg; |
194 | MAGIC *mg; |
196 | |
195 | |
197 | if (!sv_derived_from (sv, AIO_REQ_KLASS) || !SvROK (sv)) |
196 | if (!SvROK (sv) |
|
|
197 | || (SvSTASH (SvRV (sv)) != aio_grp_stash |
|
|
198 | && SvSTASH (SvRV (sv)) != aio_req_stash |
|
|
199 | && !sv_derived_from (sv, "IO::AIO::REQ"))) |
198 | croak ("object of class " AIO_REQ_KLASS " expected"); |
200 | croak ("object of class IO::AIO::REQ expected"); |
199 | |
201 | |
200 | mg = mg_find (SvRV (sv), PERL_MAGIC_ext); |
202 | mg = mg_find (SvRV (sv), PERL_MAGIC_ext); |
201 | |
203 | |
202 | return mg ? (aio_req)mg->mg_ptr : 0; |
204 | return mg ? (aio_req)mg->mg_ptr : 0; |
203 | } |
205 | } |
… | |
… | |
209 | dSP; |
211 | dSP; |
210 | |
212 | |
211 | ENTER; |
213 | ENTER; |
212 | SAVETMPS; |
214 | SAVETMPS; |
213 | PUSHMARK (SP); |
215 | PUSHMARK (SP); |
214 | XPUSHs (req_sv (grp, AIO_GRP_KLASS)); |
216 | XPUSHs (req_sv (grp, aio_grp_stash)); |
215 | PUTBACK; |
217 | PUTBACK; |
216 | call_sv (grp->sv2, G_VOID | G_EVAL | G_KEEPERR); |
218 | call_sv (grp->sv2, G_VOID | G_EVAL | G_KEEPERR); |
217 | SPAGAIN; |
219 | SPAGAIN; |
218 | FREETMPS; |
220 | FREETMPS; |
219 | LEAVE; |
221 | LEAVE; |
… | |
… | |
325 | int flags = req->int1 & (O_RDONLY | O_WRONLY | O_RDWR); |
327 | int flags = req->int1 & (O_RDONLY | O_WRONLY | O_RDWR); |
326 | char sym [64]; |
328 | char sym [64]; |
327 | int symlen; |
329 | int symlen; |
328 | |
330 | |
329 | symlen = snprintf (sym, sizeof (sym), "fd#%d", (int)req->result); |
331 | symlen = snprintf (sym, sizeof (sym), "fd#%d", (int)req->result); |
330 | gv_init (gv, stash, sym, symlen, 0); |
332 | gv_init (gv, aio_stash, sym, symlen, 0); |
331 | |
333 | |
332 | symlen = snprintf ( |
334 | symlen = snprintf ( |
333 | sym, |
335 | sym, |
334 | sizeof (sym), |
336 | sizeof (sym), |
335 | "%s&=%d", |
337 | "%s&=%d", |
… | |
… | |
438 | grp->sv2 = 0; |
440 | grp->sv2 = 0; |
439 | |
441 | |
440 | eio_grp_cancel (grp); |
442 | eio_grp_cancel (grp); |
441 | } |
443 | } |
442 | |
444 | |
443 | #ifdef USE_SOCKETS_AS_HANDLES |
|
|
444 | # define TO_SOCKET(x) (win32_get_osfhandle (x)) |
|
|
445 | #else |
|
|
446 | # define TO_SOCKET(x) (x) |
|
|
447 | #endif |
|
|
448 | |
|
|
449 | static void |
445 | static void |
450 | create_respipe (void) |
446 | create_respipe (void) |
451 | { |
447 | { |
452 | int old_readfd = respipe [0]; |
|
|
453 | |
|
|
454 | if (respipe [1] >= 0) |
|
|
455 | respipe_close (TO_SOCKET (respipe [1])); |
|
|
456 | |
|
|
457 | #ifdef _WIN32 |
|
|
458 | if (PerlSock_socketpair (AF_UNIX, SOCK_STREAM, 0, respipe)) |
|
|
459 | #else |
|
|
460 | if (pipe (respipe)) |
448 | if (s_epipe_renew (&respipe)) |
461 | #endif |
|
|
462 | croak ("unable to initialize result pipe"); |
449 | croak ("IO::AIO: unable to initialize result pipe"); |
463 | |
|
|
464 | if (old_readfd >= 0) |
|
|
465 | { |
|
|
466 | if (dup2 (TO_SOCKET (respipe [0]), TO_SOCKET (old_readfd)) < 0) |
|
|
467 | croak ("unable to initialize result pipe(2)"); |
|
|
468 | |
|
|
469 | respipe_close (respipe [0]); |
|
|
470 | respipe [0] = old_readfd; |
|
|
471 | } |
|
|
472 | |
|
|
473 | #ifdef _WIN32 |
|
|
474 | int arg = 1; |
|
|
475 | if (ioctlsocket (TO_SOCKET (respipe [0]), FIONBIO, &arg) |
|
|
476 | || ioctlsocket (TO_SOCKET (respipe [1]), FIONBIO, &arg)) |
|
|
477 | #else |
|
|
478 | if (fcntl (respipe [0], F_SETFL, O_NONBLOCK) |
|
|
479 | || fcntl (respipe [1], F_SETFL, O_NONBLOCK)) |
|
|
480 | #endif |
|
|
481 | croak ("unable to initialize result pipe(3)"); |
|
|
482 | |
|
|
483 | respipe_osf [0] = TO_SOCKET (respipe [0]); |
|
|
484 | respipe_osf [1] = TO_SOCKET (respipe [1]); |
|
|
485 | } |
450 | } |
486 | |
451 | |
487 | static void poll_wait (void) |
452 | static void poll_wait (void) |
488 | { |
453 | { |
489 | fd_set rfd; |
|
|
490 | |
|
|
491 | while (eio_nreqs ()) |
454 | while (eio_nreqs ()) |
492 | { |
455 | { |
493 | int size; |
456 | int size; |
494 | |
457 | |
495 | X_LOCK (reslock); |
458 | X_LOCK (reslock); |
… | |
… | |
499 | if (size) |
462 | if (size) |
500 | return; |
463 | return; |
501 | |
464 | |
502 | etp_maybe_start_thread (); |
465 | etp_maybe_start_thread (); |
503 | |
466 | |
504 | FD_ZERO (&rfd); |
467 | s_epipe_wait (&respipe); |
505 | FD_SET (respipe [0], &rfd); |
|
|
506 | |
|
|
507 | PerlSock_select (respipe [0] + 1, &rfd, 0, 0, 0); |
|
|
508 | } |
468 | } |
509 | } |
469 | } |
510 | |
470 | |
511 | static int poll_cb (void) |
471 | static int poll_cb (void) |
512 | { |
472 | { |
… | |
… | |
530 | } |
490 | } |
531 | |
491 | |
532 | static SV * |
492 | static SV * |
533 | get_cb (SV *cb_sv) |
493 | get_cb (SV *cb_sv) |
534 | { |
494 | { |
535 | HV *st; |
495 | SvGETMAGIC (cb_sv); |
536 | GV *gvp; |
496 | return SvOK (cb_sv) ? s_get_cv_croak (cb_sv) : 0; |
537 | CV *cv; |
|
|
538 | |
|
|
539 | if (!SvOK (cb_sv)) |
|
|
540 | return 0; |
|
|
541 | |
|
|
542 | cv = sv_2cv (cb_sv, &st, &gvp, 0); |
|
|
543 | |
|
|
544 | if (!cv) |
|
|
545 | croak ("IO::AIO callback must be undef or a CODE reference"); |
|
|
546 | |
|
|
547 | return (SV *)cv; |
|
|
548 | } |
497 | } |
549 | |
498 | |
550 | #define dREQ \ |
499 | #define dREQ \ |
551 | SV *cb_cv; \ |
500 | SV *cb_cv; \ |
552 | aio_req req; \ |
501 | aio_req req; \ |
… | |
… | |
566 | PUTBACK; \ |
515 | PUTBACK; \ |
567 | req_submit (req); \ |
516 | req_submit (req); \ |
568 | SPAGAIN; \ |
517 | SPAGAIN; \ |
569 | \ |
518 | \ |
570 | if (GIMME_V != G_VOID) \ |
519 | if (GIMME_V != G_VOID) \ |
571 | XPUSHs (req_sv (req, AIO_REQ_KLASS)); |
520 | XPUSHs (req_sv (req, aio_req_stash)); |
572 | |
|
|
573 | static int |
|
|
574 | extract_fd (SV *fh, int wr) |
|
|
575 | { |
|
|
576 | int fd = PerlIO_fileno (wr ? IoOFP (sv_2io (fh)) : IoIFP (sv_2io (fh))); |
|
|
577 | |
|
|
578 | if (fd < 0) |
|
|
579 | croak ("illegal fh argument, either not an OS file or read/write mode mismatch"); |
|
|
580 | |
|
|
581 | return fd; |
|
|
582 | } |
|
|
583 | |
521 | |
584 | MODULE = IO::AIO PACKAGE = IO::AIO |
522 | MODULE = IO::AIO PACKAGE = IO::AIO |
585 | |
523 | |
586 | PROTOTYPES: ENABLE |
524 | PROTOTYPES: ENABLE |
587 | |
525 | |
… | |
… | |
627 | const_eio (DT_LNK) |
565 | const_eio (DT_LNK) |
628 | const_eio (DT_SOCK) |
566 | const_eio (DT_SOCK) |
629 | const_eio (DT_WHT) |
567 | const_eio (DT_WHT) |
630 | }; |
568 | }; |
631 | |
569 | |
632 | stash = gv_stashpv ("IO::AIO", 1); |
570 | aio_stash = gv_stashpv ("IO::AIO" , 1); |
|
|
571 | aio_req_stash = gv_stashpv ("IO::AIO::REQ", 1); |
|
|
572 | aio_grp_stash = gv_stashpv ("IO::AIO::GRP", 1); |
633 | |
573 | |
634 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
574 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
635 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
575 | newCONSTSUB (aio_stash, (char *)civ->name, newSViv (civ->iv)); |
636 | |
576 | |
637 | create_respipe (); |
577 | create_respipe (); |
638 | |
578 | |
639 | if (eio_init (want_poll, done_poll) < 0) |
579 | if (eio_init (want_poll, done_poll) < 0) |
640 | croak ("IO::AIO: unable to initialise eio library"); |
580 | croak ("IO::AIO: unable to initialise eio library"); |
… | |
… | |
701 | ALIAS: |
641 | ALIAS: |
702 | aio_fsync = EIO_FSYNC |
642 | aio_fsync = EIO_FSYNC |
703 | aio_fdatasync = EIO_FDATASYNC |
643 | aio_fdatasync = EIO_FDATASYNC |
704 | PPCODE: |
644 | PPCODE: |
705 | { |
645 | { |
706 | int fd = extract_fd (fh, 0); |
646 | int fd = s_fileno_croak (fh, 0); |
707 | dREQ; |
647 | dREQ; |
708 | |
648 | |
709 | req->type = ix; |
649 | req->type = ix; |
710 | req->sv1 = newSVsv (fh); |
650 | req->sv1 = newSVsv (fh); |
711 | req->int1 = fd; |
651 | req->int1 = fd; |
… | |
… | |
716 | void |
656 | void |
717 | aio_sync_file_range (SV *fh, off_t offset, size_t nbytes, UV flags, SV *callback=&PL_sv_undef) |
657 | aio_sync_file_range (SV *fh, off_t offset, size_t nbytes, UV flags, SV *callback=&PL_sv_undef) |
718 | PROTOTYPE: $$$$;$ |
658 | PROTOTYPE: $$$$;$ |
719 | PPCODE: |
659 | PPCODE: |
720 | { |
660 | { |
721 | int fd = extract_fd (fh, 0); |
661 | int fd = s_fileno_croak (fh, 0); |
722 | dREQ; |
662 | dREQ; |
723 | |
663 | |
724 | req->type = EIO_SYNC_FILE_RANGE; |
664 | req->type = EIO_SYNC_FILE_RANGE; |
725 | req->sv1 = newSVsv (fh); |
665 | req->sv1 = newSVsv (fh); |
726 | req->int1 = fd; |
666 | req->int1 = fd; |
… | |
… | |
735 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
675 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
736 | PROTOTYPE: $;$ |
676 | PROTOTYPE: $;$ |
737 | PPCODE: |
677 | PPCODE: |
738 | { |
678 | { |
739 | static int close_pipe = -1; /* dummy fd to close fds via dup2 */ |
679 | static int close_pipe = -1; /* dummy fd to close fds via dup2 */ |
740 | int fd = extract_fd (fh, 0); |
680 | int fd = s_fileno_croak (fh, 0); |
741 | dREQ; |
681 | dREQ; |
742 | |
682 | |
743 | if (close_pipe < 0) |
683 | if (close_pipe < 0) |
744 | { |
684 | { |
745 | int pipefd [2]; |
685 | int pipefd [2]; |
… | |
… | |
767 | aio_write = EIO_WRITE |
707 | aio_write = EIO_WRITE |
768 | PROTOTYPE: $$$$$;$ |
708 | PROTOTYPE: $$$$$;$ |
769 | PPCODE: |
709 | PPCODE: |
770 | { |
710 | { |
771 | STRLEN svlen; |
711 | STRLEN svlen; |
772 | int fd = extract_fd (fh, ix == EIO_WRITE); |
712 | int fd = s_fileno_croak (fh, ix == EIO_WRITE); |
773 | char *svptr = SvPVbyte (data, svlen); |
713 | char *svptr = SvPVbyte (data, svlen); |
774 | UV len = SvUV (length); |
714 | UV len = SvUV (length); |
775 | |
715 | |
776 | if (dataoffset < 0) |
716 | if (dataoffset < 0) |
777 | dataoffset += svlen; |
717 | dataoffset += svlen; |
… | |
… | |
832 | void |
772 | void |
833 | aio_sendfile (SV *out_fh, SV *in_fh, off_t in_offset, size_t length, SV *callback=&PL_sv_undef) |
773 | aio_sendfile (SV *out_fh, SV *in_fh, off_t in_offset, size_t length, SV *callback=&PL_sv_undef) |
834 | PROTOTYPE: $$$$;$ |
774 | PROTOTYPE: $$$$;$ |
835 | PPCODE: |
775 | PPCODE: |
836 | { |
776 | { |
837 | int ifd = extract_fd (in_fh , 0); |
777 | int ifd = s_fileno_croak (in_fh , 0); |
838 | int ofd = extract_fd (out_fh, 0); |
778 | int ofd = s_fileno_croak (out_fh, 1); |
839 | dREQ; |
779 | dREQ; |
840 | |
780 | |
841 | req->type = EIO_SENDFILE; |
781 | req->type = EIO_SENDFILE; |
842 | req->sv1 = newSVsv (out_fh); |
782 | req->sv1 = newSVsv (out_fh); |
843 | req->int1 = ofd; |
783 | req->int1 = ofd; |
… | |
… | |
852 | void |
792 | void |
853 | aio_readahead (SV *fh, off_t offset, size_t length, SV *callback=&PL_sv_undef) |
793 | aio_readahead (SV *fh, off_t offset, size_t length, SV *callback=&PL_sv_undef) |
854 | PROTOTYPE: $$$;$ |
794 | PROTOTYPE: $$$;$ |
855 | PPCODE: |
795 | PPCODE: |
856 | { |
796 | { |
857 | int fd = extract_fd (fh, 0); |
797 | int fd = s_fileno_croak (fh, 0); |
858 | dREQ; |
798 | dREQ; |
859 | |
799 | |
860 | req->type = EIO_READAHEAD; |
800 | req->type = EIO_READAHEAD; |
861 | req->sv1 = newSVsv (fh); |
801 | req->sv1 = newSVsv (fh); |
862 | req->int1 = fd; |
802 | req->int1 = fd; |
… | |
… | |
1076 | dREQ; |
1016 | dREQ; |
1077 | |
1017 | |
1078 | req->type = EIO_GROUP; |
1018 | req->type = EIO_GROUP; |
1079 | |
1019 | |
1080 | req_submit (req); |
1020 | req_submit (req); |
1081 | XPUSHs (req_sv (req, AIO_GRP_KLASS)); |
1021 | XPUSHs (req_sv (req, aio_grp_stash)); |
1082 | } |
1022 | } |
1083 | |
1023 | |
1084 | void |
1024 | void |
1085 | aio_nop (SV *callback=&PL_sv_undef) |
1025 | aio_nop (SV *callback=&PL_sv_undef) |
1086 | ALIAS: |
1026 | ALIAS: |
… | |
… | |
1138 | |
1078 | |
1139 | int |
1079 | int |
1140 | poll_fileno() |
1080 | poll_fileno() |
1141 | PROTOTYPE: |
1081 | PROTOTYPE: |
1142 | CODE: |
1082 | CODE: |
1143 | RETVAL = respipe [0]; |
1083 | RETVAL = s_epipe_fd (&respipe); |
1144 | OUTPUT: |
1084 | OUTPUT: |
1145 | RETVAL |
1085 | RETVAL |
1146 | |
1086 | |
1147 | int |
1087 | int |
1148 | poll_cb(...) |
1088 | poll_cb(...) |
… | |
… | |
1192 | |
1132 | |
1193 | int |
1133 | int |
1194 | fadvise (aio_rfd fh, off_t offset, off_t length, IV advice) |
1134 | fadvise (aio_rfd fh, off_t offset, off_t length, IV advice) |
1195 | PROTOTYPE: $$$$ |
1135 | PROTOTYPE: $$$$ |
1196 | CODE: |
1136 | CODE: |
1197 | { |
|
|
1198 | #if _XOPEN_SOURCE >= 600 |
1137 | #if _XOPEN_SOURCE >= 600 && !NO_FADVISE |
1199 | RETVAL = posix_fadvise (fh, offset, length, advice); |
1138 | RETVAL = posix_fadvise (fh, offset, length, advice); |
1200 | #else |
1139 | #else |
1201 | RETVAL = errno = ENOSYS; |
1140 | RETVAL = errno = ENOSYS; |
1202 | #endif |
1141 | #endif |
1203 | } |
|
|
1204 | OUTPUT: |
1142 | OUTPUT: |
1205 | RETVAL |
1143 | RETVAL |
1206 | |
1144 | |
1207 | ssize_t |
1145 | ssize_t |
1208 | sendfile (aio_wfd ofh, aio_rfd ifh, off_t offset, size_t count) |
1146 | sendfile (aio_wfd ofh, aio_rfd ifh, off_t offset, size_t count) |
1209 | PROTOTYPE: $$$$ |
1147 | PROTOTYPE: $$$$ |
1210 | CODE: |
1148 | CODE: |
1211 | eio_sendfile_sync (ofh, ifh, offset, count); |
1149 | RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); |
|
|
1150 | OUTPUT: |
|
|
1151 | RETVAL |
1212 | |
1152 | |
1213 | void _on_next_submit (SV *cb) |
1153 | void _on_next_submit (SV *cb) |
1214 | CODE: |
1154 | CODE: |
1215 | SvREFCNT_dec (on_next_submit); |
1155 | SvREFCNT_dec (on_next_submit); |
1216 | on_next_submit = SvOK (cb) ? newSVsv (cb) : 0; |
1156 | on_next_submit = SvOK (cb) ? newSVsv (cb) : 0; |
… | |
… | |
1231 | if (GIMME_V != G_VOID) |
1171 | if (GIMME_V != G_VOID) |
1232 | XPUSHs (req->callback ? sv_2mortal (newRV_inc (req->callback)) : &PL_sv_undef); |
1172 | XPUSHs (req->callback ? sv_2mortal (newRV_inc (req->callback)) : &PL_sv_undef); |
1233 | |
1173 | |
1234 | if (items > 1) |
1174 | if (items > 1) |
1235 | { |
1175 | { |
1236 | SV *cb_cv = get_cb (callback); |
1176 | SV *cb_cv =get_cb (callback); |
1237 | |
1177 | |
1238 | SvREFCNT_dec (req->callback); |
1178 | SvREFCNT_dec (req->callback); |
1239 | req->callback = SvREFCNT_inc (cb_cv); |
1179 | req->callback = SvREFCNT_inc (cb_cv); |
1240 | } |
1180 | } |
1241 | } |
1181 | } |