… | |
… | |
11 | #include <stddef.h> |
11 | #include <stddef.h> |
12 | #include <stdlib.h> |
12 | #include <stdlib.h> |
13 | #include <errno.h> |
13 | #include <errno.h> |
14 | #include <sys/types.h> |
14 | #include <sys/types.h> |
15 | #include <sys/stat.h> |
15 | #include <sys/stat.h> |
16 | #include <sys/statvfs.h> |
|
|
17 | #include <limits.h> |
16 | #include <limits.h> |
18 | #include <fcntl.h> |
17 | #include <fcntl.h> |
19 | #include <sched.h> |
18 | #include <sched.h> |
20 | |
19 | |
21 | #if _POSIX_MEMLOCK || _POSIX_MEMLOCK_RANGE || _POSIX_MAPPED_FILES |
20 | #if _POSIX_MEMLOCK || _POSIX_MEMLOCK_RANGE || _POSIX_MAPPED_FILES |
22 | # include <sys/mman.h> |
21 | # include <sys/mman.h> |
23 | #endif |
22 | #endif |
24 | |
23 | |
25 | /* perl namespace pollution */ |
24 | /* perl namespace pollution */ |
26 | #undef VERSION |
25 | #undef VERSION |
27 | |
|
|
28 | #ifdef _WIN32 |
|
|
29 | |
|
|
30 | # define EIO_STRUCT_DIRENT Direntry_t |
|
|
31 | # undef malloc |
|
|
32 | # undef free |
|
|
33 | |
|
|
34 | // perl overrides all those nice win32 functions |
|
|
35 | # undef open |
|
|
36 | # undef read |
|
|
37 | # undef write |
|
|
38 | # undef send |
|
|
39 | # undef recv |
|
|
40 | # undef stat |
|
|
41 | # undef fstat |
|
|
42 | # define lstat stat |
|
|
43 | # undef truncate |
|
|
44 | # undef ftruncate |
|
|
45 | # undef open |
|
|
46 | # undef close |
|
|
47 | # undef unlink |
|
|
48 | # undef rmdir |
|
|
49 | # undef rename |
|
|
50 | # undef lseek |
|
|
51 | |
|
|
52 | # define chown(a,b,c) (errno = ENOSYS, -1) |
|
|
53 | # define fchown(a,b,c) (errno = ENOSYS, -1) |
|
|
54 | # define fchmod(a,b) (errno = ENOSYS, -1) |
|
|
55 | # define symlink(a,b) (errno = ENOSYS, -1) |
|
|
56 | # define readlink(a,b,c) (errno = ENOSYS, -1) |
|
|
57 | # define mknod(a,b,c) (errno = ENOSYS, -1) |
|
|
58 | # define truncate(a,b) (errno = ENOSYS, -1) |
|
|
59 | # define ftruncate(fd,o) chsize ((fd), (o)) |
|
|
60 | # define fsync(fd) _commit (fd) |
|
|
61 | # define opendir(fd) (errno = ENOSYS, 0) |
|
|
62 | # define readdir(fd) (errno = ENOSYS, -1) |
|
|
63 | # define closedir(fd) (errno = ENOSYS, -1) |
|
|
64 | # define mkdir(a,b) mkdir (a) |
|
|
65 | |
|
|
66 | #else |
|
|
67 | |
|
|
68 | # include <sys/time.h> |
|
|
69 | # include <sys/select.h> |
|
|
70 | # include <unistd.h> |
|
|
71 | # include <utime.h> |
|
|
72 | # include <signal.h> |
|
|
73 | # define EIO_STRUCT_DIRENT struct dirent |
|
|
74 | |
|
|
75 | #endif |
|
|
76 | |
26 | |
77 | /* perl stupidly overrides readdir and maybe others */ |
27 | /* perl stupidly overrides readdir and maybe others */ |
78 | /* with thread-unsafe versions, imagine that :( */ |
28 | /* with thread-unsafe versions, imagine that :( */ |
79 | #undef readdir |
29 | #undef readdir |
80 | #undef opendir |
30 | #undef opendir |
81 | #undef closedir |
31 | #undef closedir |
|
|
32 | |
|
|
33 | #ifdef _WIN32 |
|
|
34 | |
|
|
35 | // perl overrides all those nice libc functions |
|
|
36 | |
|
|
37 | #undef malloc |
|
|
38 | #undef free |
|
|
39 | #undef open |
|
|
40 | #undef read |
|
|
41 | #undef write |
|
|
42 | #undef send |
|
|
43 | #undef recv |
|
|
44 | #undef stat |
|
|
45 | #undef lstat |
|
|
46 | #undef fstat |
|
|
47 | #undef truncate |
|
|
48 | #undef ftruncate |
|
|
49 | #undef open |
|
|
50 | #undef link |
|
|
51 | #undef close |
|
|
52 | #undef unlink |
|
|
53 | #undef mkdir |
|
|
54 | #undef rmdir |
|
|
55 | #undef rename |
|
|
56 | #undef lseek |
|
|
57 | #undef opendir |
|
|
58 | #undef readdir |
|
|
59 | #undef closedir |
|
|
60 | #undef chmod |
|
|
61 | #undef fchmod |
|
|
62 | #undef dup |
|
|
63 | #undef dup2 |
|
|
64 | #undef abort |
|
|
65 | #undef pipe |
|
|
66 | |
|
|
67 | #else |
|
|
68 | |
|
|
69 | #include <sys/time.h> |
|
|
70 | #include <sys/select.h> |
|
|
71 | #include <unistd.h> |
|
|
72 | #include <utime.h> |
|
|
73 | #include <signal.h> |
|
|
74 | |
|
|
75 | #endif |
82 | |
76 | |
83 | #define EIO_STRUCT_STAT Stat_t |
77 | #define EIO_STRUCT_STAT Stat_t |
84 | |
78 | |
85 | /* use NV for 32 bit perls as it allows larger offsets */ |
79 | /* use NV for 32 bit perls as it allows larger offsets */ |
86 | #if IVSIZE >= 8 |
80 | #if IVSIZE >= 8 |
… | |
… | |
121 | #define EIO_NO_WRAPPERS 1 |
115 | #define EIO_NO_WRAPPERS 1 |
122 | |
116 | |
123 | #include "libeio/config.h" |
117 | #include "libeio/config.h" |
124 | #include "libeio/eio.h" |
118 | #include "libeio/eio.h" |
125 | |
119 | |
|
|
120 | static int req_invoke (eio_req *req); |
|
|
121 | #define EIO_FINISH(req) req_invoke (req) |
|
|
122 | static void req_destroy (eio_req *grp); |
|
|
123 | #define EIO_DESTROY(req) req_destroy (req) |
|
|
124 | |
|
|
125 | #include "libeio/eio.c" |
|
|
126 | |
|
|
127 | /* Linux/others */ |
|
|
128 | #ifndef O_ASYNC |
|
|
129 | # define O_ASYNC 0 |
|
|
130 | #endif |
|
|
131 | #ifndef O_DIRECT |
|
|
132 | # define O_DIRECT 0 |
|
|
133 | #endif |
|
|
134 | #ifndef O_NOATIME |
|
|
135 | # define O_NOATIME 0 |
|
|
136 | #endif |
|
|
137 | |
|
|
138 | /* POSIX */ |
|
|
139 | #ifndef O_CLOEXEC |
|
|
140 | # define O_CLOEXEC 0 |
|
|
141 | #endif |
|
|
142 | #ifndef O_NOFOLLOW |
|
|
143 | # define O_NOFOLLOW 0 |
|
|
144 | #endif |
|
|
145 | #ifndef O_NOCTTY |
|
|
146 | # define O_NOCTTY 0 |
|
|
147 | #endif |
|
|
148 | #ifndef O_NONBLOCK |
|
|
149 | # define O_NONBLOCK 0 |
|
|
150 | #endif |
|
|
151 | #ifndef O_EXEC |
|
|
152 | # define O_EXEC 0 |
|
|
153 | #endif |
|
|
154 | #ifndef O_SEARCH |
|
|
155 | # define O_SEARCH 0 |
|
|
156 | #endif |
|
|
157 | #ifndef O_DIRECTORY |
|
|
158 | # define O_DIRECTORY 0 |
|
|
159 | #endif |
|
|
160 | #ifndef O_DSYNC |
|
|
161 | # define O_DSYNC 0 |
|
|
162 | #endif |
|
|
163 | #ifndef O_RSYNC |
|
|
164 | # define O_RSYNC 0 |
|
|
165 | #endif |
|
|
166 | #ifndef O_SYNC |
|
|
167 | # define O_SYNC 0 |
|
|
168 | #endif |
|
|
169 | #ifndef O_TTY_INIT |
|
|
170 | # define O_TTY_INIT 0 |
|
|
171 | #endif |
|
|
172 | |
126 | #ifndef POSIX_FADV_NORMAL |
173 | #ifndef POSIX_FADV_NORMAL |
127 | # define POSIX_FADV_NORMAL 0 |
174 | # define POSIX_FADV_NORMAL 0 |
128 | #endif |
175 | #endif |
129 | #ifndef POSIX_FADV_SEQUENTIAL |
176 | #ifndef POSIX_FADV_SEQUENTIAL |
130 | # define POSIX_FADV_SEQUENTIAL 0 |
177 | # define POSIX_FADV_SEQUENTIAL 0 |
… | |
… | |
177 | #endif |
224 | #endif |
178 | #ifndef PROT_EXEC |
225 | #ifndef PROT_EXEC |
179 | # define PROT_EXEC 0 |
226 | # define PROT_EXEC 0 |
180 | #endif |
227 | #endif |
181 | |
228 | |
|
|
229 | #ifndef ST_RDONLY |
|
|
230 | # define ST_RDONLY 0 |
|
|
231 | #endif |
|
|
232 | #ifndef ST_NOSUID |
|
|
233 | # define ST_NOSUID 0 |
|
|
234 | #endif |
182 | #ifndef ST_NODEV |
235 | #ifndef ST_NODEV |
183 | # define ST_NODEV 0 |
236 | # define ST_NODEV 0 |
184 | #endif |
237 | #endif |
185 | #ifndef ST_NOEXEC |
238 | #ifndef ST_NOEXEC |
186 | # define ST_NOEXEC 0 |
239 | # define ST_NOEXEC 0 |
… | |
… | |
270 | |
323 | |
271 | #ifndef PAGESIZE |
324 | #ifndef PAGESIZE |
272 | # define PAGESIZE sysconf (_SC_PAGESIZE) |
325 | # define PAGESIZE sysconf (_SC_PAGESIZE) |
273 | #endif |
326 | #endif |
274 | |
327 | |
275 | static int req_invoke (eio_req *req); |
|
|
276 | #define EIO_FINISH(req) req_invoke (req) |
|
|
277 | static void req_destroy (eio_req *grp); |
|
|
278 | #define EIO_DESTROY(req) req_destroy (req) |
|
|
279 | |
|
|
280 | enum { |
328 | enum { |
281 | FLAG_SV2_RO_OFF = 0x40, /* data was set readonly */ |
329 | FLAG_SV2_RO_OFF = 0x40, /* data was set readonly */ |
282 | }; |
330 | }; |
283 | |
|
|
284 | #include "libeio/eio.c" |
|
|
285 | |
331 | |
286 | typedef eio_req *aio_req; |
332 | typedef eio_req *aio_req; |
287 | typedef eio_req *aio_req_ornot; |
333 | typedef eio_req *aio_req_ornot; |
288 | |
334 | |
289 | static SV *on_next_submit; |
335 | static SV *on_next_submit; |
… | |
… | |
495 | case EIO_STATVFS: |
541 | case EIO_STATVFS: |
496 | case EIO_FSTATVFS: |
542 | case EIO_FSTATVFS: |
497 | { |
543 | { |
498 | SV *rv = &PL_sv_undef; |
544 | SV *rv = &PL_sv_undef; |
499 | |
545 | |
|
|
546 | #ifndef _WIN32 |
500 | if (req->result >= 0) |
547 | if (req->result >= 0) |
501 | { |
548 | { |
502 | EIO_STRUCT_STATVFS *f = EIO_STATVFS_BUF (req); |
549 | EIO_STRUCT_STATVFS *f = EIO_STATVFS_BUF (req); |
503 | HV *hv = newHV (); |
550 | HV *hv = newHV (); |
504 | |
551 | |
… | |
… | |
514 | hv_store (hv, "favail" , sizeof ("favail" ) - 1, newSVval64 (f->f_favail ), 0); |
561 | hv_store (hv, "favail" , sizeof ("favail" ) - 1, newSVval64 (f->f_favail ), 0); |
515 | hv_store (hv, "fsid" , sizeof ("fsid" ) - 1, newSVval64 (f->f_fsid ), 0); |
562 | hv_store (hv, "fsid" , sizeof ("fsid" ) - 1, newSVval64 (f->f_fsid ), 0); |
516 | hv_store (hv, "flag" , sizeof ("flag" ) - 1, newSVval64 (f->f_flag ), 0); |
563 | hv_store (hv, "flag" , sizeof ("flag" ) - 1, newSVval64 (f->f_flag ), 0); |
517 | hv_store (hv, "namemax", sizeof ("namemax") - 1, newSVval64 (f->f_namemax), 0); |
564 | hv_store (hv, "namemax", sizeof ("namemax") - 1, newSVval64 (f->f_namemax), 0); |
518 | } |
565 | } |
|
|
566 | #endif |
519 | |
567 | |
520 | PUSHs (rv); |
568 | PUSHs (rv); |
521 | } |
569 | } |
522 | |
570 | |
523 | break; |
571 | break; |
… | |
… | |
539 | case EIO_NOP: |
587 | case EIO_NOP: |
540 | case EIO_BUSY: |
588 | case EIO_BUSY: |
541 | break; |
589 | break; |
542 | |
590 | |
543 | case EIO_READLINK: |
591 | case EIO_READLINK: |
|
|
592 | case EIO_REALPATH: |
544 | if (req->result > 0) |
593 | if (req->result > 0) |
545 | PUSHs (sv_2mortal (newSVpvn (req->ptr2, req->result))); |
594 | PUSHs (sv_2mortal (newSVpvn (req->ptr2, req->result))); |
546 | break; |
595 | break; |
547 | |
596 | |
548 | case EIO_STAT: |
597 | case EIO_STAT: |
549 | case EIO_LSTAT: |
598 | case EIO_LSTAT: |
550 | case EIO_FSTAT: |
599 | case EIO_FSTAT: |
551 | PL_laststype = req->type == EIO_LSTAT ? OP_LSTAT : OP_STAT; |
600 | PL_laststype = req->type == EIO_LSTAT ? OP_LSTAT : OP_STAT; |
552 | PL_laststatval = req->result; |
601 | PL_laststatval = req->result; |
|
|
602 | /* if compilation fails here then perl's Stat_t is not struct _stati64 */ |
553 | PL_statcache = *(EIO_STRUCT_STAT *)(req->ptr2); |
603 | PL_statcache = *(EIO_STRUCT_STAT *)(req->ptr2); |
554 | PUSHs (sv_result); |
604 | PUSHs (sv_result); |
555 | break; |
605 | break; |
556 | |
606 | |
557 | case EIO_READ: |
607 | case EIO_READ: |
… | |
… | |
609 | Safefree (req); |
659 | Safefree (req); |
610 | } |
660 | } |
611 | |
661 | |
612 | static void req_cancel_subs (aio_req grp) |
662 | static void req_cancel_subs (aio_req grp) |
613 | { |
663 | { |
614 | aio_req sub; |
|
|
615 | |
|
|
616 | if (grp->type != EIO_GROUP) |
664 | if (grp->type != EIO_GROUP) |
617 | return; |
665 | return; |
618 | |
666 | |
619 | SvREFCNT_dec (grp->sv2); |
667 | SvREFCNT_dec (grp->sv2); |
620 | grp->sv2 = 0; |
668 | grp->sv2 = 0; |
621 | |
669 | |
622 | eio_grp_cancel (grp); |
670 | eio_grp_cancel (grp); |
623 | } |
671 | } |
624 | |
672 | |
625 | static void |
|
|
626 | create_respipe (void) |
673 | static void create_respipe (void) |
627 | { |
674 | { |
628 | if (s_epipe_renew (&respipe)) |
675 | if (s_epipe_renew (&respipe)) |
629 | croak ("IO::AIO: unable to initialize result pipe"); |
676 | croak ("IO::AIO: unable to initialize result pipe"); |
630 | } |
677 | } |
631 | |
678 | |
… | |
… | |
662 | |
709 | |
663 | poll_wait (); |
710 | poll_wait (); |
664 | } |
711 | } |
665 | } |
712 | } |
666 | |
713 | |
667 | static void atfork_child (void) |
714 | static void ecb_cold |
|
|
715 | reinit (void) |
668 | { |
716 | { |
669 | create_respipe (); |
717 | create_respipe (); |
|
|
718 | |
|
|
719 | if (eio_init (want_poll, done_poll) < 0) |
|
|
720 | croak ("IO::AIO: unable to initialise eio library"); |
670 | } |
721 | } |
671 | |
722 | |
672 | /*****************************************************************************/ |
723 | /*****************************************************************************/ |
673 | |
724 | |
674 | #if !_POSIX_MAPPED_FILES |
725 | #if !_POSIX_MAPPED_FILES |
… | |
… | |
685 | # define MAP_FIXED 0 |
736 | # define MAP_FIXED 0 |
686 | #endif |
737 | #endif |
687 | |
738 | |
688 | #define MMAP_MAGIC PERL_MAGIC_ext |
739 | #define MMAP_MAGIC PERL_MAGIC_ext |
689 | |
740 | |
690 | static int |
|
|
691 | mmap_free (pTHX_ SV *sv, MAGIC *mg) |
741 | static int mmap_free (pTHX_ SV *sv, MAGIC *mg) |
692 | { |
742 | { |
693 | int old_errno = errno; |
743 | int old_errno = errno; |
694 | munmap (mg->mg_ptr, (size_t)mg->mg_obj); |
744 | munmap (mg->mg_ptr, (size_t)mg->mg_obj); |
695 | errno = old_errno; |
745 | errno = old_errno; |
696 | |
746 | |
… | |
… | |
712 | 0, 0, 0, 0, mmap_free |
762 | 0, 0, 0, 0, mmap_free |
713 | }; |
763 | }; |
714 | |
764 | |
715 | /*****************************************************************************/ |
765 | /*****************************************************************************/ |
716 | |
766 | |
717 | static SV * |
|
|
718 | get_cb (SV *cb_sv) |
767 | static SV * get_cb (SV *cb_sv) |
719 | { |
768 | { |
720 | SvGETMAGIC (cb_sv); |
769 | SvGETMAGIC (cb_sv); |
721 | return SvOK (cb_sv) ? s_get_cv_croak (cb_sv) : 0; |
770 | return SvOK (cb_sv) ? s_get_cv_croak (cb_sv) : 0; |
722 | } |
771 | } |
723 | |
772 | |
… | |
… | |
765 | const_iv (O_CREAT) |
814 | const_iv (O_CREAT) |
766 | const_iv (O_TRUNC) |
815 | const_iv (O_TRUNC) |
767 | const_iv (O_EXCL) |
816 | const_iv (O_EXCL) |
768 | const_iv (O_APPEND) |
817 | const_iv (O_APPEND) |
769 | |
818 | |
|
|
819 | const_iv (O_ASYNC) |
|
|
820 | const_iv (O_DIRECT) |
|
|
821 | const_iv (O_NOATIME) |
|
|
822 | |
|
|
823 | const_iv (O_CLOEXEC) |
|
|
824 | const_iv (O_NOCTTY) |
|
|
825 | const_iv (O_NOFOLLOW) |
|
|
826 | const_iv (O_NONBLOCK) |
|
|
827 | const_iv (O_EXEC) |
|
|
828 | const_iv (O_SEARCH) |
|
|
829 | const_iv (O_DIRECTORY) |
|
|
830 | const_iv (O_DSYNC) |
|
|
831 | const_iv (O_RSYNC) |
|
|
832 | const_iv (O_SYNC) |
|
|
833 | const_iv (O_TTY_INIT) |
|
|
834 | |
770 | const_iv (S_IFIFO) |
835 | const_iv (S_IFIFO) |
771 | const_iv (S_IFCHR) |
836 | const_iv (S_IFCHR) |
772 | const_iv (S_IFBLK) |
837 | const_iv (S_IFBLK) |
773 | const_iv (S_IFLNK) |
838 | const_iv (S_IFLNK) |
774 | const_iv (S_IFREG) |
839 | const_iv (S_IFREG) |
… | |
… | |
831 | |
896 | |
832 | const_eio (SYNC_FILE_RANGE_WAIT_BEFORE) |
897 | const_eio (SYNC_FILE_RANGE_WAIT_BEFORE) |
833 | const_eio (SYNC_FILE_RANGE_WRITE) |
898 | const_eio (SYNC_FILE_RANGE_WRITE) |
834 | const_eio (SYNC_FILE_RANGE_WAIT_AFTER) |
899 | const_eio (SYNC_FILE_RANGE_WAIT_AFTER) |
835 | |
900 | |
|
|
901 | const_eio (FALLOC_FL_KEEP_SIZE) |
|
|
902 | |
836 | const_eio (READDIR_DENTS) |
903 | const_eio (READDIR_DENTS) |
837 | const_eio (READDIR_DIRS_FIRST) |
904 | const_eio (READDIR_DIRS_FIRST) |
838 | const_eio (READDIR_STAT_ORDER) |
905 | const_eio (READDIR_STAT_ORDER) |
839 | const_eio (READDIR_FOUND_UNKNOWN) |
906 | const_eio (READDIR_FOUND_UNKNOWN) |
840 | |
907 | |
… | |
… | |
856 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
923 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
857 | newCONSTSUB (aio_stash, (char *)civ->name, newSViv (civ->iv)); |
924 | newCONSTSUB (aio_stash, (char *)civ->name, newSViv (civ->iv)); |
858 | |
925 | |
859 | newCONSTSUB (aio_stash, "PAGESIZE", newSViv (PAGESIZE)); |
926 | newCONSTSUB (aio_stash, "PAGESIZE", newSViv (PAGESIZE)); |
860 | |
927 | |
861 | create_respipe (); |
928 | reinit (); |
862 | |
|
|
863 | if (eio_init (want_poll, done_poll) < 0) |
|
|
864 | croak ("IO::AIO: unable to initialise eio library"); |
|
|
865 | |
|
|
866 | /* atfork child called in fifo order, so before eio's handler */ |
|
|
867 | X_THREAD_ATFORK (0, 0, atfork_child); |
|
|
868 | } |
929 | } |
869 | |
930 | |
870 | void |
931 | void |
|
|
932 | reinit () |
|
|
933 | PROTOTYPE: |
|
|
934 | CODE: |
|
|
935 | reinit (); |
|
|
936 | |
|
|
937 | void |
871 | max_poll_reqs (int nreqs) |
938 | max_poll_reqs (unsigned int nreqs) |
872 | PROTOTYPE: $ |
939 | PROTOTYPE: $ |
873 | CODE: |
940 | CODE: |
874 | eio_set_max_poll_reqs (nreqs); |
941 | eio_set_max_poll_reqs (nreqs); |
875 | |
942 | |
876 | void |
943 | void |
… | |
… | |
878 | PROTOTYPE: $ |
945 | PROTOTYPE: $ |
879 | CODE: |
946 | CODE: |
880 | eio_set_max_poll_time (nseconds); |
947 | eio_set_max_poll_time (nseconds); |
881 | |
948 | |
882 | void |
949 | void |
883 | min_parallel (int nthreads) |
950 | min_parallel (unsigned int nthreads) |
884 | PROTOTYPE: $ |
951 | PROTOTYPE: $ |
885 | CODE: |
952 | CODE: |
886 | eio_set_min_parallel (nthreads); |
953 | eio_set_min_parallel (nthreads); |
887 | |
954 | |
888 | void |
955 | void |
889 | max_parallel (int nthreads) |
956 | max_parallel (unsigned int nthreads) |
890 | PROTOTYPE: $ |
957 | PROTOTYPE: $ |
891 | CODE: |
958 | CODE: |
892 | eio_set_max_parallel (nthreads); |
959 | eio_set_max_parallel (nthreads); |
893 | |
960 | |
894 | void |
961 | void |
895 | max_idle (int nthreads) |
962 | max_idle (unsigned int nthreads) |
896 | PROTOTYPE: $ |
963 | PROTOTYPE: $ |
897 | CODE: |
964 | CODE: |
898 | eio_set_max_idle (nthreads); |
965 | eio_set_max_idle (nthreads); |
899 | |
966 | |
900 | void |
967 | void |
|
|
968 | idle_timeout (unsigned int seconds) |
|
|
969 | PROTOTYPE: $ |
|
|
970 | CODE: |
|
|
971 | eio_set_idle_timeout (seconds); |
|
|
972 | |
|
|
973 | void |
901 | max_outstanding (int maxreqs) |
974 | max_outstanding (unsigned int maxreqs) |
902 | PROTOTYPE: $ |
975 | PROTOTYPE: $ |
903 | CODE: |
976 | CODE: |
904 | max_outstanding = maxreqs; |
977 | max_outstanding = maxreqs; |
905 | |
978 | |
906 | void |
979 | void |
… | |
… | |
951 | |
1024 | |
952 | REQ_SEND (req); |
1025 | REQ_SEND (req); |
953 | } |
1026 | } |
954 | |
1027 | |
955 | void |
1028 | void |
|
|
1029 | aio_fallocate (SV *fh, int mode, off_t offset, size_t len, SV *callback=&PL_sv_undef) |
|
|
1030 | PPCODE: |
|
|
1031 | { |
|
|
1032 | int fd = s_fileno_croak (fh, 0); |
|
|
1033 | dREQ; |
|
|
1034 | |
|
|
1035 | req->type = EIO_FALLOCATE; |
|
|
1036 | req->sv1 = newSVsv (fh); |
|
|
1037 | req->int1 = fd; |
|
|
1038 | req->int2 = mode; |
|
|
1039 | req->offs = offset; |
|
|
1040 | req->size = len; |
|
|
1041 | |
|
|
1042 | REQ_SEND (req); |
|
|
1043 | } |
|
|
1044 | |
|
|
1045 | void |
956 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
1046 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
957 | PPCODE: |
1047 | PPCODE: |
958 | { |
1048 | { |
959 | static int close_pipe = -1; /* dummy fd to close fds via dup2 */ |
1049 | static int close_fd = -1; /* dummy fd to close fds via dup2 */ |
960 | int fd = s_fileno_croak (fh, 0); |
1050 | int fd = s_fileno_croak (fh, 0); |
961 | dREQ; |
1051 | dREQ; |
962 | |
1052 | |
963 | if (close_pipe < 0) |
1053 | if (expect_false (close_fd < 0)) |
964 | { |
1054 | { |
965 | int pipefd [2]; |
1055 | int pipefd [2]; |
966 | |
1056 | |
|
|
1057 | if ( |
|
|
1058 | #ifdef _WIN32 |
|
|
1059 | _pipe (pipefd, 1, _O_BINARY) < 0 |
|
|
1060 | #else |
967 | if (pipe (pipefd) < 0 |
1061 | pipe (pipefd) < 0 |
968 | || close (pipefd [1]) < 0 |
|
|
969 | || fcntl (pipefd [0], F_SETFD, FD_CLOEXEC) < 0) |
1062 | || fcntl (pipefd [0], F_SETFD, FD_CLOEXEC) < 0 |
|
|
1063 | #endif |
|
|
1064 | || close (pipefd [1]) < 0 |
|
|
1065 | ) |
970 | abort (); /*D*/ |
1066 | abort (); /*D*/ |
971 | |
1067 | |
972 | close_pipe = pipefd [0]; |
1068 | close_fd = pipefd [0]; |
973 | } |
1069 | } |
974 | |
1070 | |
975 | req->type = EIO_DUP2; |
1071 | req->type = EIO_DUP2; |
976 | req->int1 = close_pipe; |
1072 | req->int1 = close_fd; |
977 | req->sv2 = newSVsv (fh); |
1073 | req->sv2 = newSVsv (fh); |
978 | req->int2 = fd; |
1074 | req->int2 = fd; |
979 | |
1075 | |
980 | REQ_SEND (req); |
1076 | REQ_SEND (req); |
981 | } |
1077 | } |
… | |
… | |
1033 | } |
1129 | } |
1034 | } |
1130 | } |
1035 | |
1131 | |
1036 | void |
1132 | void |
1037 | aio_readlink (SV8 *path, SV *callback=&PL_sv_undef) |
1133 | aio_readlink (SV8 *path, SV *callback=&PL_sv_undef) |
|
|
1134 | ALIAS: |
|
|
1135 | aio_readlink = EIO_READLINK |
|
|
1136 | aio_realpath = EIO_REALPATH |
1038 | PPCODE: |
1137 | PPCODE: |
1039 | { |
1138 | { |
1040 | SV *data; |
|
|
1041 | dREQ; |
1139 | dREQ; |
1042 | |
1140 | |
1043 | req->type = EIO_READLINK; |
1141 | req->type = ix; |
1044 | req->sv1 = newSVsv (path); |
1142 | req->sv1 = newSVsv (path); |
1045 | req->ptr1 = SvPVbyte_nolen (req->sv1); |
1143 | req->ptr1 = SvPVbyte_nolen (req->sv1); |
1046 | |
1144 | |
1047 | REQ_SEND; |
1145 | REQ_SEND; |
1048 | } |
1146 | } |
… | |
… | |
1492 | CODE: |
1590 | CODE: |
1493 | RETVAL = posix_fadvise (fh, offset, length, advice); |
1591 | RETVAL = posix_fadvise (fh, offset, length, advice); |
1494 | OUTPUT: |
1592 | OUTPUT: |
1495 | RETVAL |
1593 | RETVAL |
1496 | |
1594 | |
1497 | ssize_t |
1595 | IV |
1498 | sendfile (aio_wfd ofh, aio_rfd ifh, off_t offset, size_t count) |
1596 | sendfile (aio_wfd ofh, aio_rfd ifh, off_t offset, size_t count) |
1499 | CODE: |
1597 | CODE: |
1500 | RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); |
1598 | RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); |
1501 | OUTPUT: |
1599 | OUTPUT: |
1502 | RETVAL |
1600 | RETVAL |