… | |
… | |
62 | #undef dup |
62 | #undef dup |
63 | #undef dup2 |
63 | #undef dup2 |
64 | #undef abort |
64 | #undef abort |
65 | #undef pipe |
65 | #undef pipe |
66 | |
66 | |
|
|
67 | #define EIO_STRUCT_STAT struct _stati64 |
|
|
68 | #define EIO_STRUCT_STATI64 |
|
|
69 | |
67 | #else |
70 | #else |
68 | |
71 | |
69 | #include <sys/time.h> |
72 | #include <sys/time.h> |
70 | #include <sys/select.h> |
73 | #include <sys/select.h> |
71 | #include <unistd.h> |
74 | #include <unistd.h> |
72 | #include <utime.h> |
75 | #include <utime.h> |
73 | #include <signal.h> |
76 | #include <signal.h> |
74 | |
77 | |
75 | #endif |
|
|
76 | |
|
|
77 | #define EIO_STRUCT_STAT Stat_t |
78 | #define EIO_STRUCT_STAT Stat_t |
|
|
79 | |
|
|
80 | #endif |
78 | |
81 | |
79 | /* use NV for 32 bit perls as it allows larger offsets */ |
82 | /* use NV for 32 bit perls as it allows larger offsets */ |
80 | #if IVSIZE >= 8 |
83 | #if IVSIZE >= 8 |
81 | # define VAL64 IV |
84 | # define VAL64 IV |
82 | # define SvVAL64 SvIV |
85 | # define SvVAL64 SvIV |
… | |
… | |
341 | static s_epipe respipe; |
344 | static s_epipe respipe; |
342 | |
345 | |
343 | static void req_destroy (aio_req req); |
346 | static void req_destroy (aio_req req); |
344 | static void req_cancel (aio_req req); |
347 | static void req_cancel (aio_req req); |
345 | |
348 | |
346 | static void want_poll (void) |
349 | static void |
|
|
350 | want_poll (void) |
347 | { |
351 | { |
348 | /* write a dummy byte to the pipe so fh becomes ready */ |
352 | /* write a dummy byte to the pipe so fh becomes ready */ |
349 | s_epipe_signal (&respipe); |
353 | s_epipe_signal (&respipe); |
350 | } |
354 | } |
351 | |
355 | |
352 | static void done_poll (void) |
356 | static void |
|
|
357 | done_poll (void) |
353 | { |
358 | { |
354 | /* read any signals sent by the worker threads */ |
359 | /* read any signals sent by the worker threads */ |
355 | s_epipe_drain (&respipe); |
360 | s_epipe_drain (&respipe); |
356 | } |
361 | } |
357 | |
362 | |
358 | /* must be called at most once */ |
363 | /* must be called at most once */ |
|
|
364 | static SV * |
359 | static SV *req_sv (aio_req req, HV *stash) |
365 | req_sv (aio_req req, HV *stash) |
360 | { |
366 | { |
361 | if (!req->self) |
367 | if (!req->self) |
362 | { |
368 | { |
363 | req->self = (SV *)newHV (); |
369 | req->self = (SV *)newHV (); |
364 | sv_magic (req->self, 0, PERL_MAGIC_ext, (char *)req, 0); |
370 | sv_magic (req->self, 0, PERL_MAGIC_ext, (char *)req, 0); |
… | |
… | |
368 | } |
374 | } |
369 | |
375 | |
370 | static SV * |
376 | static SV * |
371 | newSVaio_wd (aio_wd wd) |
377 | newSVaio_wd (aio_wd wd) |
372 | { |
378 | { |
373 | return sv_bless (newRV_noinc (newSViv ((long)wd)), aio_wd_stash); |
379 | return sv_bless (newRV_noinc (newSViv ((IV)wd)), aio_wd_stash); |
374 | } |
380 | } |
375 | |
381 | |
376 | static aio_req SvAIO_REQ (SV *sv) |
382 | static aio_req |
|
|
383 | SvAIO_REQ (SV *sv) |
377 | { |
384 | { |
378 | MAGIC *mg; |
385 | MAGIC *mg; |
379 | |
386 | |
380 | if (!SvROK (sv) |
387 | if (!SvROK (sv) |
|
|
388 | /* for speed reasons, we do not verify that SvROK actually has a stash ptr */ |
381 | || (SvSTASH (SvRV (sv)) != aio_grp_stash |
389 | || (SvSTASH (SvRV (sv)) != aio_grp_stash |
382 | && SvSTASH (SvRV (sv)) != aio_req_stash |
390 | && SvSTASH (SvRV (sv)) != aio_req_stash |
383 | && !sv_derived_from (sv, "IO::AIO::REQ"))) |
391 | && !sv_derived_from (sv, "IO::AIO::REQ"))) |
384 | croak ("object of class IO::AIO::REQ expected"); |
392 | croak ("object of class IO::AIO::REQ expected"); |
385 | |
393 | |
386 | mg = mg_find (SvRV (sv), PERL_MAGIC_ext); |
394 | mg = mg_find (SvRV (sv), PERL_MAGIC_ext); |
387 | |
395 | |
388 | return mg ? (aio_req)mg->mg_ptr : 0; |
396 | return mg ? (aio_req)mg->mg_ptr : 0; |
389 | } |
397 | } |
390 | |
398 | |
391 | static aio_wd SvAIO_WD (SV *sv) |
399 | static aio_wd |
|
|
400 | SvAIO_WD (SV *sv) |
392 | { |
401 | { |
393 | if (!SvROK (sv) |
402 | if (!SvROK (sv) |
|
|
403 | || SvTYPE (SvRV (sv)) != SVt_PVMG |
394 | || SvSTASH (SvRV (sv)) != aio_wd_stash |
404 | || SvSTASH (SvRV (sv)) != aio_wd_stash) |
395 | || SvTYPE (SvRV (sv)) != SVt_PVMG) |
|
|
396 | croak ("IO::AIO: expected a working directory object as returned by aio_wd"); |
405 | croak ("IO::AIO: expected a working directory object as returned by aio_wd"); |
397 | |
406 | |
398 | return (aio_wd)(long)SvIVX (SvRV (sv)); |
407 | return (aio_wd)(long)SvIVX (SvRV (sv)); |
399 | } |
408 | } |
400 | |
409 | |
|
|
410 | static void |
401 | static void aio_grp_feed (aio_req grp) |
411 | aio_grp_feed (aio_req grp) |
402 | { |
412 | { |
403 | if (grp->sv2 && SvOK (grp->sv2)) |
413 | if (grp->sv2 && SvOK (grp->sv2)) |
404 | { |
414 | { |
405 | dSP; |
415 | dSP; |
406 | |
416 | |
… | |
… | |
414 | FREETMPS; |
424 | FREETMPS; |
415 | LEAVE; |
425 | LEAVE; |
416 | } |
426 | } |
417 | } |
427 | } |
418 | |
428 | |
|
|
429 | static void |
419 | static void req_submit (eio_req *req) |
430 | req_submit (eio_req *req) |
420 | { |
431 | { |
421 | eio_submit (req); |
432 | eio_submit (req); |
422 | |
433 | |
423 | if (expect_false (on_next_submit)) |
434 | if (expect_false (on_next_submit)) |
424 | { |
435 | { |
… | |
… | |
431 | PUTBACK; |
442 | PUTBACK; |
432 | call_sv (cb, G_DISCARD | G_EVAL); |
443 | call_sv (cb, G_DISCARD | G_EVAL); |
433 | } |
444 | } |
434 | } |
445 | } |
435 | |
446 | |
|
|
447 | static int |
436 | static int req_invoke (eio_req *req) |
448 | req_invoke (eio_req *req) |
437 | { |
449 | { |
438 | if (req->flags & FLAG_SV2_RO_OFF) |
450 | if (req->flags & FLAG_SV2_RO_OFF) |
439 | SvREADONLY_off (req->sv2); |
451 | SvREADONLY_off (req->sv2); |
440 | |
452 | |
441 | if (!EIO_CANCELLED (req) && req->callback) |
453 | if (!EIO_CANCELLED (req) && req->callback) |
… | |
… | |
463 | } |
475 | } |
464 | |
476 | |
465 | switch (req->type) |
477 | switch (req->type) |
466 | { |
478 | { |
467 | case EIO_WD_OPEN: |
479 | case EIO_WD_OPEN: |
468 | PUSHs (sv_2mortal (newSVaio_wd (req->wd))); |
480 | PUSHs (req->result ? &PL_sv_undef : sv_2mortal (newSVaio_wd (req->wd))); |
469 | break; |
481 | break; |
470 | |
482 | |
471 | case EIO_READDIR: |
483 | case EIO_READDIR: |
472 | { |
484 | { |
473 | SV *rv = &PL_sv_undef; |
485 | SV *rv = &PL_sv_undef; |
… | |
… | |
626 | PL_statcache = *(EIO_STRUCT_STAT *)(req->ptr2); |
638 | PL_statcache = *(EIO_STRUCT_STAT *)(req->ptr2); |
627 | |
639 | |
628 | PUSHs (sv_result); |
640 | PUSHs (sv_result); |
629 | break; |
641 | break; |
630 | |
642 | |
|
|
643 | case EIO_SEEK: |
|
|
644 | PUSHs (req->result ? sv_result : sv_2mortal (newSVval64 (req->offs))); |
|
|
645 | break; |
|
|
646 | |
631 | case EIO_READ: |
647 | case EIO_READ: |
632 | { |
648 | { |
633 | SvCUR_set (req->sv2, req->stroffset + (req->result > 0 ? req->result : 0)); |
649 | SvCUR_set (req->sv2, req->stroffset + (req->result > 0 ? req->result : 0)); |
634 | *SvEND (req->sv2) = 0; |
650 | *SvEND (req->sv2) = 0; |
635 | SvPOK_only (req->sv2); |
651 | SvPOK_only (req->sv2); |
… | |
… | |
666 | } |
682 | } |
667 | |
683 | |
668 | return !!SvTRUE (ERRSV); |
684 | return !!SvTRUE (ERRSV); |
669 | } |
685 | } |
670 | |
686 | |
|
|
687 | static void |
671 | static void req_destroy (aio_req req) |
688 | req_destroy (aio_req req) |
672 | { |
689 | { |
673 | if (req->self) |
690 | if (req->self) |
674 | { |
691 | { |
675 | sv_unmagic (req->self, PERL_MAGIC_ext); |
692 | sv_unmagic (req->self, PERL_MAGIC_ext); |
676 | SvREFCNT_dec (req->self); |
693 | SvREFCNT_dec (req->self); |
… | |
… | |
680 | SvREFCNT_dec (req->sv2); |
697 | SvREFCNT_dec (req->sv2); |
681 | SvREFCNT_dec (req->sv3); |
698 | SvREFCNT_dec (req->sv3); |
682 | SvREFCNT_dec (req->sv4); |
699 | SvREFCNT_dec (req->sv4); |
683 | SvREFCNT_dec (req->callback); |
700 | SvREFCNT_dec (req->callback); |
684 | |
701 | |
685 | Safefree (req); |
702 | free (req); |
686 | } |
703 | } |
687 | |
704 | |
|
|
705 | static void |
688 | static void req_cancel_subs (aio_req grp) |
706 | req_cancel_subs (aio_req grp) |
689 | { |
707 | { |
690 | if (grp->type != EIO_GROUP) |
708 | if (grp->type != EIO_GROUP) |
691 | return; |
709 | return; |
692 | |
710 | |
693 | SvREFCNT_dec (grp->sv2); |
711 | SvREFCNT_dec (grp->sv2); |
694 | grp->sv2 = 0; |
712 | grp->sv2 = 0; |
695 | |
713 | |
696 | eio_grp_cancel (grp); |
714 | eio_grp_cancel (grp); |
697 | } |
715 | } |
698 | |
716 | |
|
|
717 | static void ecb_cold |
699 | static void create_respipe (void) |
718 | create_respipe (void) |
700 | { |
719 | { |
701 | if (s_epipe_renew (&respipe)) |
720 | if (s_epipe_renew (&respipe)) |
702 | croak ("IO::AIO: unable to initialize result pipe"); |
721 | croak ("IO::AIO: unable to initialize result pipe"); |
703 | } |
722 | } |
704 | |
723 | |
705 | static void poll_wait (void) |
724 | static void |
|
|
725 | poll_wait (void) |
706 | { |
726 | { |
707 | while (eio_nreqs ()) |
727 | while (eio_nreqs ()) |
708 | { |
728 | { |
709 | int size; |
729 | int size; |
710 | |
730 | |
… | |
… | |
719 | |
739 | |
720 | s_epipe_wait (&respipe); |
740 | s_epipe_wait (&respipe); |
721 | } |
741 | } |
722 | } |
742 | } |
723 | |
743 | |
724 | static int poll_cb (void) |
744 | static int |
|
|
745 | poll_cb (void) |
725 | { |
746 | { |
726 | for (;;) |
747 | for (;;) |
727 | { |
748 | { |
728 | int res = eio_poll (); |
749 | int res = eio_poll (); |
729 | |
750 | |
… | |
… | |
762 | # define MAP_FIXED 0 |
783 | # define MAP_FIXED 0 |
763 | #endif |
784 | #endif |
764 | |
785 | |
765 | #define MMAP_MAGIC PERL_MAGIC_ext |
786 | #define MMAP_MAGIC PERL_MAGIC_ext |
766 | |
787 | |
|
|
788 | static int ecb_cold |
767 | static int mmap_free (pTHX_ SV *sv, MAGIC *mg) |
789 | mmap_free (pTHX_ SV *sv, MAGIC *mg) |
768 | { |
790 | { |
769 | int old_errno = errno; |
791 | int old_errno = errno; |
770 | munmap (mg->mg_ptr, (size_t)mg->mg_obj); |
792 | munmap (mg->mg_ptr, (size_t)mg->mg_obj); |
771 | errno = old_errno; |
793 | errno = old_errno; |
772 | |
794 | |
… | |
… | |
788 | 0, 0, 0, 0, mmap_free |
810 | 0, 0, 0, 0, mmap_free |
789 | }; |
811 | }; |
790 | |
812 | |
791 | /*****************************************************************************/ |
813 | /*****************************************************************************/ |
792 | |
814 | |
|
|
815 | static SV * |
793 | static SV * get_cb (SV *cb_sv) |
816 | get_cb (SV *cb_sv) |
794 | { |
817 | { |
795 | SvGETMAGIC (cb_sv); |
818 | SvGETMAGIC (cb_sv); |
796 | return SvOK (cb_sv) ? s_get_cv_croak (cb_sv) : 0; |
819 | return SvOK (cb_sv) ? s_get_cv_croak (cb_sv) : 0; |
797 | } |
820 | } |
798 | |
821 | |
|
|
822 | static aio_req ecb_noinline |
|
|
823 | dreq (SV *callback) |
|
|
824 | { |
|
|
825 | SV *cb_cv; |
|
|
826 | aio_req req; |
|
|
827 | int req_pri = next_pri; |
|
|
828 | next_pri = EIO_PRI_DEFAULT; |
|
|
829 | |
|
|
830 | cb_cv = get_cb (callback); |
|
|
831 | |
|
|
832 | req = calloc (sizeof (*req), 1); |
|
|
833 | if (!req) |
|
|
834 | croak ("out of memory during eio_req allocation"); |
|
|
835 | |
|
|
836 | req->callback = SvREFCNT_inc (cb_cv); |
|
|
837 | req->pri = req_pri; |
|
|
838 | |
|
|
839 | return req; |
|
|
840 | } |
|
|
841 | |
799 | #define dREQ \ |
842 | #define dREQ \ |
800 | SV *cb_cv; \ |
843 | aio_req req = dreq (callback); \ |
801 | aio_req req; \ |
|
|
802 | int req_pri = next_pri; \ |
|
|
803 | next_pri = EIO_PRI_DEFAULT; \ |
|
|
804 | \ |
|
|
805 | cb_cv = get_cb (callback); \ |
|
|
806 | \ |
|
|
807 | Newz (0, req, 1, eio_req); \ |
|
|
808 | if (!req) \ |
|
|
809 | croak ("out of memory during eio_req allocation"); \ |
|
|
810 | \ |
|
|
811 | req->callback = SvREFCNT_inc (cb_cv); \ |
|
|
812 | req->pri = req_pri |
|
|
813 | |
844 | |
814 | #define REQ_SEND \ |
845 | #define REQ_SEND \ |
815 | PUTBACK; \ |
846 | PUTBACK; \ |
816 | req_submit (req); \ |
847 | req_submit (req); \ |
817 | SPAGAIN; \ |
848 | SPAGAIN; \ |
818 | \ |
849 | \ |
819 | if (GIMME_V != G_VOID) \ |
850 | if (GIMME_V != G_VOID) \ |
820 | XPUSHs (req_sv (req, aio_req_stash)); |
851 | XPUSHs (req_sv (req, aio_req_stash)); |
821 | |
852 | |
822 | static void |
853 | ecb_inline void |
823 | req_set_path (aio_req req, SV *path, SV **wdsv, SV **pathsv, eio_wd *wd, void **ptr) |
854 | req_set_path (aio_req req, SV *path, SV **wdsv, SV **pathsv, eio_wd *wd, void **ptr) |
824 | { |
855 | { |
825 | if (expect_false (SvROK (path))) |
856 | if (expect_false (SvROK (path))) |
826 | { |
857 | { |
827 | AV *av = (AV *)SvRV (path); |
858 | SV *rv = SvRV (path); |
828 | SV *wdob; |
859 | SV *wdob; |
829 | |
860 | |
830 | if (SvTYPE (av) != SVt_PVAV || AvFILLp (av) != 1) |
861 | if (SvTYPE (rv) == SVt_PVAV && AvFILLp (rv) == 1) |
831 | croak ("IO::AIO: pathname arguments must be specified as strings or [wd, path] arrayrefs"); |
|
|
832 | |
|
|
833 | path = AvARRAY (av)[1]; |
|
|
834 | wdob = AvARRAY (av)[0]; |
|
|
835 | |
|
|
836 | if (SvOK (wdob)) |
|
|
837 | { |
862 | { |
|
|
863 | path = AvARRAY (rv)[1]; |
|
|
864 | wdob = AvARRAY (rv)[0]; |
|
|
865 | |
|
|
866 | if (SvOK (wdob)) |
|
|
867 | { |
838 | *wd = SvAIO_WD (wdob); |
868 | *wd = SvAIO_WD (wdob); |
839 | *wdsv = SvREFCNT_inc_NN (SvRV (wdob)); |
869 | *wdsv = SvREFCNT_inc_NN (SvRV (wdob)); |
|
|
870 | } |
|
|
871 | else |
|
|
872 | *wd = EIO_INVALID_WD; |
|
|
873 | } |
|
|
874 | else if (SvTYPE (rv) == SVt_PVMG && SvSTASH (rv) == aio_wd_stash) |
|
|
875 | { |
|
|
876 | *wd = (aio_wd)(long)SvIVX (rv); |
|
|
877 | *wdsv = SvREFCNT_inc_NN (rv); |
|
|
878 | *ptr = "."; |
|
|
879 | return; /* path set to "." */ |
840 | } |
880 | } |
841 | else |
881 | else |
842 | *wd = EIO_INVALID_WD; |
882 | croak ("IO::AIO: pathname arguments must be specified as a string, an IO::AIO::WD object or a [IO::AIO::WD, path] pair"); |
843 | } |
883 | } |
844 | |
884 | |
845 | *pathsv = newSVsv (path); |
885 | *pathsv = newSVsv (path); |
846 | *ptr = SvPVbyte_nolen (*pathsv); |
886 | *ptr = SvPVbyte_nolen (*pathsv); |
847 | } |
887 | } |
848 | |
888 | |
849 | static void |
889 | static void ecb_noinline |
850 | req_set_path1 (aio_req req, SV *path) |
890 | req_set_path1 (aio_req req, SV *path) |
851 | { |
891 | { |
852 | req_set_path (req, path, &req->sv1, &req->sv3, &req->wd, &req->ptr1); |
892 | req_set_path (req, path, &req->sv1, &req->sv3, &req->wd, &req->ptr1); |
853 | } |
893 | } |
854 | |
894 | |
855 | static void |
895 | static void ecb_noinline |
856 | req_set_fh_or_path (aio_req req, int type_path, int type_fh, SV *fh_or_path) |
896 | req_set_fh_or_path (aio_req req, int type_path, int type_fh, SV *fh_or_path) |
857 | { |
897 | { |
858 | SV *rv = SvROK (fh_or_path) ? SvRV (fh_or_path) : fh_or_path; |
898 | SV *rv = SvROK (fh_or_path) ? SvRV (fh_or_path) : fh_or_path; |
859 | |
899 | |
860 | switch (SvTYPE (rv)) |
900 | switch (SvTYPE (rv)) |
… | |
… | |
870 | default: |
910 | default: |
871 | req->type = type_path; |
911 | req->type = type_path; |
872 | req_set_path1 (req, fh_or_path); |
912 | req_set_path1 (req, fh_or_path); |
873 | break; |
913 | break; |
874 | } |
914 | } |
875 | |
|
|
876 | } |
915 | } |
|
|
916 | |
|
|
917 | XS(boot_IO__AIO) ecb_cold; |
877 | |
918 | |
878 | MODULE = IO::AIO PACKAGE = IO::AIO |
919 | MODULE = IO::AIO PACKAGE = IO::AIO |
879 | |
920 | |
880 | PROTOTYPES: ENABLE |
921 | PROTOTYPES: ENABLE |
881 | |
922 | |
… | |
… | |
965 | const_iv (MAP_LOCKED) |
1006 | const_iv (MAP_LOCKED) |
966 | const_iv (MAP_NORESERVE) |
1007 | const_iv (MAP_NORESERVE) |
967 | const_iv (MAP_POPULATE) |
1008 | const_iv (MAP_POPULATE) |
968 | const_iv (MAP_NONBLOCK) |
1009 | const_iv (MAP_NONBLOCK) |
969 | |
1010 | |
|
|
1011 | const_eio (SEEK_SET) |
|
|
1012 | const_eio (SEEK_CUR) |
|
|
1013 | const_eio (SEEK_END) |
|
|
1014 | |
970 | const_eio (MCL_FUTURE) |
1015 | const_eio (MCL_FUTURE) |
971 | const_eio (MCL_CURRENT) |
1016 | const_eio (MCL_CURRENT) |
972 | |
1017 | |
973 | const_eio (MS_ASYNC) |
1018 | const_eio (MS_ASYNC) |
974 | const_eio (MS_INVALIDATE) |
1019 | const_eio (MS_INVALIDATE) |
… | |
… | |
1096 | |
1141 | |
1097 | req->type = ix; |
1142 | req->type = ix; |
1098 | req->sv1 = newSVsv (fh); |
1143 | req->sv1 = newSVsv (fh); |
1099 | req->int1 = fd; |
1144 | req->int1 = fd; |
1100 | |
1145 | |
1101 | REQ_SEND (req); |
1146 | REQ_SEND; |
1102 | } |
1147 | } |
1103 | |
1148 | |
1104 | void |
1149 | void |
1105 | aio_sync_file_range (SV *fh, off_t offset, size_t nbytes, UV flags, SV *callback=&PL_sv_undef) |
1150 | aio_sync_file_range (SV *fh, off_t offset, size_t nbytes, UV flags, SV *callback=&PL_sv_undef) |
1106 | PPCODE: |
1151 | PPCODE: |
… | |
… | |
1113 | req->int1 = fd; |
1158 | req->int1 = fd; |
1114 | req->offs = offset; |
1159 | req->offs = offset; |
1115 | req->size = nbytes; |
1160 | req->size = nbytes; |
1116 | req->int2 = flags; |
1161 | req->int2 = flags; |
1117 | |
1162 | |
1118 | REQ_SEND (req); |
1163 | REQ_SEND; |
1119 | } |
1164 | } |
1120 | |
1165 | |
1121 | void |
1166 | void |
1122 | aio_fallocate (SV *fh, int mode, off_t offset, size_t len, SV *callback=&PL_sv_undef) |
1167 | aio_fallocate (SV *fh, int mode, off_t offset, size_t len, SV *callback=&PL_sv_undef) |
1123 | PPCODE: |
1168 | PPCODE: |
… | |
… | |
1130 | req->int1 = fd; |
1175 | req->int1 = fd; |
1131 | req->int2 = mode; |
1176 | req->int2 = mode; |
1132 | req->offs = offset; |
1177 | req->offs = offset; |
1133 | req->size = len; |
1178 | req->size = len; |
1134 | |
1179 | |
1135 | REQ_SEND (req); |
1180 | REQ_SEND; |
1136 | } |
1181 | } |
1137 | |
1182 | |
1138 | void |
1183 | void |
1139 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
1184 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
1140 | PPCODE: |
1185 | PPCODE: |
… | |
… | |
1164 | req->type = EIO_DUP2; |
1209 | req->type = EIO_DUP2; |
1165 | req->int1 = close_fd; |
1210 | req->int1 = close_fd; |
1166 | req->sv2 = newSVsv (fh); |
1211 | req->sv2 = newSVsv (fh); |
1167 | req->int2 = fd; |
1212 | req->int2 = fd; |
1168 | |
1213 | |
1169 | REQ_SEND (req); |
1214 | REQ_SEND; |
|
|
1215 | } |
|
|
1216 | |
|
|
1217 | void |
|
|
1218 | aio_seek (SV *fh, SV *offset, int whence, SV *callback=&PL_sv_undef) |
|
|
1219 | PPCODE: |
|
|
1220 | { |
|
|
1221 | STRLEN svlen; |
|
|
1222 | int fd = s_fileno_croak (fh, 0); |
|
|
1223 | dREQ; |
|
|
1224 | |
|
|
1225 | req->type = EIO_SEEK; |
|
|
1226 | req->sv1 = newSVsv (fh); |
|
|
1227 | req->int1 = fd; |
|
|
1228 | req->offs = SvVAL64 (offset); |
|
|
1229 | req->int2 = whence; |
|
|
1230 | |
|
|
1231 | REQ_SEND; |
1170 | } |
1232 | } |
1171 | |
1233 | |
1172 | void |
1234 | void |
1173 | aio_read (SV *fh, SV *offset, SV *length, SV8 *data, IV dataoffset, SV *callback=&PL_sv_undef) |
1235 | aio_read (SV *fh, SV *offset, SV *length, SV8 *data, IV dataoffset, SV *callback=&PL_sv_undef) |
1174 | ALIAS: |
1236 | ALIAS: |
… | |
… | |
1280 | aio_statvfs = EIO_STATVFS |
1342 | aio_statvfs = EIO_STATVFS |
1281 | PPCODE: |
1343 | PPCODE: |
1282 | { |
1344 | { |
1283 | dREQ; |
1345 | dREQ; |
1284 | |
1346 | |
1285 | req->sv1 = newSVsv (fh_or_path); |
|
|
1286 | req_set_fh_or_path (req, ix, ix == EIO_STATVFS ? EIO_FSTATVFS : EIO_FSTAT, fh_or_path); |
1347 | req_set_fh_or_path (req, ix, ix == EIO_STATVFS ? EIO_FSTATVFS : EIO_FSTAT, fh_or_path); |
|
|
1348 | |
1287 | REQ_SEND; |
1349 | REQ_SEND; |
1288 | } |
1350 | } |
1289 | |
1351 | |
1290 | UV |
1352 | UV |
1291 | major (UV dev) |
1353 | major (UV dev) |
… | |
… | |
1405 | aio_link = EIO_LINK |
1467 | aio_link = EIO_LINK |
1406 | aio_symlink = EIO_SYMLINK |
1468 | aio_symlink = EIO_SYMLINK |
1407 | aio_rename = EIO_RENAME |
1469 | aio_rename = EIO_RENAME |
1408 | PPCODE: |
1470 | PPCODE: |
1409 | { |
1471 | { |
|
|
1472 | eio_wd wd2 = 0; |
1410 | dREQ; |
1473 | dREQ; |
1411 | eio_wd wd2 = 0; |
|
|
1412 | |
1474 | |
1413 | req->type = ix; |
1475 | req->type = ix; |
1414 | req_set_path1 (req, oldpath); |
1476 | req_set_path1 (req, oldpath); |
1415 | req_set_path (req, newpath, &req->sv2, &req->sv4, &wd2, &req->ptr2); |
1477 | req_set_path (req, newpath, &req->sv2, &req->sv4, &wd2, &req->ptr2); |
1416 | req->int3 = (long)wd2; |
1478 | req->int3 = (long)wd2; |
… | |
… | |
1771 | DESTROY (SV *self) |
1833 | DESTROY (SV *self) |
1772 | CODE: |
1834 | CODE: |
1773 | { |
1835 | { |
1774 | aio_wd wd = SvAIO_WD (self); |
1836 | aio_wd wd = SvAIO_WD (self); |
1775 | #if HAVE_AT |
1837 | #if HAVE_AT |
|
|
1838 | { |
1776 | SV *callback = &PL_sv_undef; |
1839 | SV *callback = &PL_sv_undef; |
1777 | dREQ; /* clobbers next_pri :/ */ |
1840 | dREQ; /* clobbers next_pri :/ */ |
|
|
1841 | next_pri = req->pri; /* restore next_pri */ |
|
|
1842 | req->pri = EIO_PRI_MAX; /* better use max. priority to conserve fds */ |
1778 | req->type = EIO_WD_CLOSE; |
1843 | req->type = EIO_WD_CLOSE; |
1779 | req->wd = wd; |
1844 | req->wd = wd; |
1780 | REQ_SEND; |
1845 | REQ_SEND; |
|
|
1846 | } |
1781 | #else |
1847 | #else |
1782 | eio_wd_close_sync (wd); |
1848 | eio_wd_close_sync (wd); |
1783 | #endif |
1849 | #endif |
1784 | } |
1850 | } |
1785 | |
1851 | |