ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/IO-AIO/AIO.xs
(Generate patch)

Comparing IO-AIO/AIO.xs (file contents):
Revision 1.180 by root, Fri Feb 11 00:05:17 2011 UTC vs.
Revision 1.209 by root, Sun Apr 1 17:46:02 2012 UTC

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
82 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 #define EIO_STRUCT_STAT struct _stati64
68 #define EIO_STRUCT_STATI64
69
70#else
71
72 #include <sys/time.h>
73 #include <sys/select.h>
74 #include <unistd.h>
75 #include <utime.h>
76 #include <signal.h>
77
83#define EIO_STRUCT_STAT Stat_t 78 #define EIO_STRUCT_STAT Stat_t
79
80#endif
84 81
85/* use NV for 32 bit perls as it allows larger offsets */ 82/* use NV for 32 bit perls as it allows larger offsets */
86#if IVSIZE >= 8 83#if IVSIZE >= 8
87# define VAL64 IV 84# define VAL64 IV
88# define SvVAL64 SvIV 85# define SvVAL64 SvIV
108 105
109typedef SV SV8; /* byte-sv, used for argument-checking */ 106typedef SV SV8; /* byte-sv, used for argument-checking */
110typedef int aio_rfd; /* read file desriptor */ 107typedef int aio_rfd; /* read file desriptor */
111typedef int aio_wfd; /* write file descriptor */ 108typedef int aio_wfd; /* write file descriptor */
112 109
113static HV *aio_stash, *aio_req_stash, *aio_grp_stash; 110static HV *aio_stash, *aio_req_stash, *aio_grp_stash, *aio_wd_stash;
114 111
115#define EIO_REQ_MEMBERS \ 112#define EIO_REQ_MEMBERS \
116 SV *callback; \ 113 SV *callback; \
117 SV *sv1, *sv2; \ 114 SV *sv1, *sv2; \
115 SV *sv3, *sv4; \
118 STRLEN stroffset; \ 116 STRLEN stroffset; \
119 SV *self; 117 SV *self;
120 118
121#define EIO_NO_WRAPPERS 1 119#define EIO_NO_WRAPPERS 1
122 120
123#include "libeio/config.h" 121#include "libeio/config.h"
124#include "libeio/eio.h" 122#include "libeio/eio.h"
125 123
124static int req_invoke (eio_req *req);
125#define EIO_FINISH(req) req_invoke (req)
126static void req_destroy (eio_req *grp);
127#define EIO_DESTROY(req) req_destroy (req)
128
129#include "libeio/eio.c"
130
131/* Linux/others */
132#ifndef O_ASYNC
133# define O_ASYNC 0
134#endif
135#ifndef O_DIRECT
136# define O_DIRECT 0
137#endif
138#ifndef O_NOATIME
139# define O_NOATIME 0
140#endif
141
142/* POSIX */
143#ifndef O_CLOEXEC
144# define O_CLOEXEC 0
145#endif
146#ifndef O_NOFOLLOW
147# define O_NOFOLLOW 0
148#endif
149#ifndef O_NOCTTY
150# define O_NOCTTY 0
151#endif
152#ifndef O_NONBLOCK
153# define O_NONBLOCK 0
154#endif
155#ifndef O_EXEC
156# define O_EXEC 0
157#endif
158#ifndef O_SEARCH
159# define O_SEARCH 0
160#endif
161#ifndef O_DIRECTORY
162# define O_DIRECTORY 0
163#endif
164#ifndef O_DSYNC
165# define O_DSYNC 0
166#endif
167#ifndef O_RSYNC
168# define O_RSYNC 0
169#endif
170#ifndef O_SYNC
171# define O_SYNC 0
172#endif
173#ifndef O_TTY_INIT
174# define O_TTY_INIT 0
175#endif
176
126#ifndef POSIX_FADV_NORMAL 177#ifndef POSIX_FADV_NORMAL
127# define POSIX_FADV_NORMAL 0 178# define POSIX_FADV_NORMAL 0
128#endif 179#endif
129#ifndef POSIX_FADV_SEQUENTIAL 180#ifndef POSIX_FADV_SEQUENTIAL
130# define POSIX_FADV_SEQUENTIAL 0 181# define POSIX_FADV_SEQUENTIAL 0
177#endif 228#endif
178#ifndef PROT_EXEC 229#ifndef PROT_EXEC
179# define PROT_EXEC 0 230# define PROT_EXEC 0
180#endif 231#endif
181 232
233#ifndef ST_RDONLY
234# define ST_RDONLY 0
235#endif
236#ifndef ST_NOSUID
237# define ST_NOSUID 0
238#endif
182#ifndef ST_NODEV 239#ifndef ST_NODEV
183# define ST_NODEV 0 240# define ST_NODEV 0
184#endif 241#endif
185#ifndef ST_NOEXEC 242#ifndef ST_NOEXEC
186# define ST_NOEXEC 0 243# define ST_NOEXEC 0
270 327
271#ifndef PAGESIZE 328#ifndef PAGESIZE
272# define PAGESIZE sysconf (_SC_PAGESIZE) 329# define PAGESIZE sysconf (_SC_PAGESIZE)
273#endif 330#endif
274 331
275static int req_invoke (eio_req *req);
276#define EIO_FINISH(req) req_invoke (req)
277static void req_destroy (eio_req *grp);
278#define EIO_DESTROY(req) req_destroy (req)
279
280enum { 332enum {
281 FLAG_SV2_RO_OFF = 0x40, /* data was set readonly */ 333 FLAG_SV2_RO_OFF = 0x40, /* data was set readonly */
282}; 334};
283 335
284#include "libeio/eio.c"
285
286typedef eio_req *aio_req; 336typedef eio_req *aio_req;
287typedef eio_req *aio_req_ornot; 337typedef eio_req *aio_req_ornot;
338typedef eio_wd aio_wd;
288 339
289static SV *on_next_submit; 340static SV *on_next_submit;
290static int next_pri = EIO_PRI_DEFAULT; 341static int next_pri = EIO_PRI_DEFAULT;
291static int max_outstanding; 342static int max_outstanding;
292 343
293static s_epipe respipe; 344static s_epipe respipe;
294 345
295static void req_destroy (aio_req req); 346static void req_destroy (aio_req req);
296static void req_cancel (aio_req req); 347static void req_cancel (aio_req req);
297 348
298static void want_poll (void) 349static void
350want_poll (void)
299{ 351{
300 /* write a dummy byte to the pipe so fh becomes ready */ 352 /* write a dummy byte to the pipe so fh becomes ready */
301 s_epipe_signal (&respipe); 353 s_epipe_signal (&respipe);
302} 354}
303 355
304static void done_poll (void) 356static void
357done_poll (void)
305{ 358{
306 /* read any signals sent by the worker threads */ 359 /* read any signals sent by the worker threads */
307 s_epipe_drain (&respipe); 360 s_epipe_drain (&respipe);
308} 361}
309 362
310/* must be called at most once */ 363/* must be called at most once */
364static SV *
311static SV *req_sv (aio_req req, HV *stash) 365req_sv (aio_req req, HV *stash)
312{ 366{
313 if (!req->self) 367 if (!req->self)
314 { 368 {
315 req->self = (SV *)newHV (); 369 req->self = (SV *)newHV ();
316 sv_magic (req->self, 0, PERL_MAGIC_ext, (char *)req, 0); 370 sv_magic (req->self, 0, PERL_MAGIC_ext, (char *)req, 0);
317 } 371 }
318 372
319 return sv_2mortal (sv_bless (newRV_inc (req->self), stash)); 373 return sv_2mortal (sv_bless (newRV_inc (req->self), stash));
320} 374}
321 375
322static aio_req SvAIO_REQ (SV *sv) 376static SV *
377newSVaio_wd (aio_wd wd)
378{
379 return sv_bless (newRV_noinc (newSViv ((IV)wd)), aio_wd_stash);
380}
381
382static aio_req
383SvAIO_REQ (SV *sv)
323{ 384{
324 MAGIC *mg; 385 MAGIC *mg;
325 386
326 if (!SvROK (sv) 387 if (!SvROK (sv)
388 /* for speed reasons, we do not verify that SvROK actually has a stash ptr */
327 || (SvSTASH (SvRV (sv)) != aio_grp_stash 389 || (SvSTASH (SvRV (sv)) != aio_grp_stash
328 && SvSTASH (SvRV (sv)) != aio_req_stash 390 && SvSTASH (SvRV (sv)) != aio_req_stash
329 && !sv_derived_from (sv, "IO::AIO::REQ"))) 391 && !sv_derived_from (sv, "IO::AIO::REQ")))
330 croak ("object of class IO::AIO::REQ expected"); 392 croak ("object of class IO::AIO::REQ expected");
331 393
332 mg = mg_find (SvRV (sv), PERL_MAGIC_ext); 394 mg = mg_find (SvRV (sv), PERL_MAGIC_ext);
333 395
334 return mg ? (aio_req)mg->mg_ptr : 0; 396 return mg ? (aio_req)mg->mg_ptr : 0;
335} 397}
336 398
399static aio_wd
400SvAIO_WD (SV *sv)
401{
402 if (!SvROK (sv)
403 || SvTYPE (SvRV (sv)) != SVt_PVMG
404 || SvSTASH (SvRV (sv)) != aio_wd_stash)
405 croak ("IO::AIO: expected a working directory object as returned by aio_wd");
406
407 return (aio_wd)(long)SvIVX (SvRV (sv));
408}
409
410static void
337static void aio_grp_feed (aio_req grp) 411aio_grp_feed (aio_req grp)
338{ 412{
339 if (grp->sv2 && SvOK (grp->sv2)) 413 if (grp->sv2 && SvOK (grp->sv2))
340 { 414 {
341 dSP; 415 dSP;
342 416
350 FREETMPS; 424 FREETMPS;
351 LEAVE; 425 LEAVE;
352 } 426 }
353} 427}
354 428
429static void
355static void req_submit (eio_req *req) 430req_submit (eio_req *req)
356{ 431{
357 eio_submit (req); 432 eio_submit (req);
358 433
359 if (expect_false (on_next_submit)) 434 if (expect_false (on_next_submit))
360 { 435 {
367 PUTBACK; 442 PUTBACK;
368 call_sv (cb, G_DISCARD | G_EVAL); 443 call_sv (cb, G_DISCARD | G_EVAL);
369 } 444 }
370} 445}
371 446
447static int
372static int req_invoke (eio_req *req) 448req_invoke (eio_req *req)
373{ 449{
374 if (req->flags & FLAG_SV2_RO_OFF) 450 if (req->flags & FLAG_SV2_RO_OFF)
375 SvREADONLY_off (req->sv2); 451 SvREADONLY_off (req->sv2);
376 452
377 if (!EIO_CANCELLED (req) && req->callback) 453 if (!EIO_CANCELLED (req) && req->callback)
398 SvREADONLY_on (sv_result); 474 SvREADONLY_on (sv_result);
399 } 475 }
400 476
401 switch (req->type) 477 switch (req->type)
402 { 478 {
479 case EIO_WD_OPEN:
480 PUSHs (req->result ? &PL_sv_undef : sv_2mortal (newSVaio_wd (req->wd)));
481 break;
482
403 case EIO_READDIR: 483 case EIO_READDIR:
404 { 484 {
405 SV *rv = &PL_sv_undef; 485 SV *rv = &PL_sv_undef;
406 486
407 if (req->result >= 0) 487 if (req->result >= 0)
495 case EIO_STATVFS: 575 case EIO_STATVFS:
496 case EIO_FSTATVFS: 576 case EIO_FSTATVFS:
497 { 577 {
498 SV *rv = &PL_sv_undef; 578 SV *rv = &PL_sv_undef;
499 579
580#ifndef _WIN32
500 if (req->result >= 0) 581 if (req->result >= 0)
501 { 582 {
502 EIO_STRUCT_STATVFS *f = EIO_STATVFS_BUF (req); 583 EIO_STRUCT_STATVFS *f = EIO_STATVFS_BUF (req);
503 HV *hv = newHV (); 584 HV *hv = newHV ();
504 585
514 hv_store (hv, "favail" , sizeof ("favail" ) - 1, newSVval64 (f->f_favail ), 0); 595 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); 596 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); 597 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); 598 hv_store (hv, "namemax", sizeof ("namemax") - 1, newSVval64 (f->f_namemax), 0);
518 } 599 }
600#endif
519 601
520 PUSHs (rv); 602 PUSHs (rv);
521 } 603 }
522 604
523 break; 605 break;
539 case EIO_NOP: 621 case EIO_NOP:
540 case EIO_BUSY: 622 case EIO_BUSY:
541 break; 623 break;
542 624
543 case EIO_READLINK: 625 case EIO_READLINK:
626 case EIO_REALPATH:
544 if (req->result > 0) 627 if (req->result > 0)
545 PUSHs (sv_2mortal (newSVpvn (req->ptr2, req->result))); 628 PUSHs (sv_2mortal (newSVpvn (req->ptr2, req->result)));
546 break; 629 break;
547 630
548 case EIO_STAT: 631 case EIO_STAT:
549 case EIO_LSTAT: 632 case EIO_LSTAT:
550 case EIO_FSTAT: 633 case EIO_FSTAT:
551 PL_laststype = req->type == EIO_LSTAT ? OP_LSTAT : OP_STAT; 634 PL_laststype = req->type == EIO_LSTAT ? OP_LSTAT : OP_STAT;
635
552 PL_laststatval = req->result; 636 if (!(PL_laststatval = req->result))
637 /* if compilation fails here then perl's Stat_t is not struct _stati64 */
553 PL_statcache = *(EIO_STRUCT_STAT *)(req->ptr2); 638 PL_statcache = *(EIO_STRUCT_STAT *)(req->ptr2);
639
554 PUSHs (sv_result); 640 PUSHs (sv_result);
641 break;
642
643 case EIO_SEEK:
644 PUSHs (req->result ? sv_result : sv_2mortal (newSVval64 (req->offs)));
555 break; 645 break;
556 646
557 case EIO_READ: 647 case EIO_READ:
558 { 648 {
559 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));
592 } 682 }
593 683
594 return !!SvTRUE (ERRSV); 684 return !!SvTRUE (ERRSV);
595} 685}
596 686
687static void
597static void req_destroy (aio_req req) 688req_destroy (aio_req req)
598{ 689{
599 if (req->self) 690 if (req->self)
600 { 691 {
601 sv_unmagic (req->self, PERL_MAGIC_ext); 692 sv_unmagic (req->self, PERL_MAGIC_ext);
602 SvREFCNT_dec (req->self); 693 SvREFCNT_dec (req->self);
603 } 694 }
604 695
605 SvREFCNT_dec (req->sv1); 696 SvREFCNT_dec (req->sv1);
606 SvREFCNT_dec (req->sv2); 697 SvREFCNT_dec (req->sv2);
698 SvREFCNT_dec (req->sv3);
699 SvREFCNT_dec (req->sv4);
607 SvREFCNT_dec (req->callback); 700 SvREFCNT_dec (req->callback);
608 701
609 Safefree (req); 702 free (req);
610} 703}
611 704
705static void
612static void req_cancel_subs (aio_req grp) 706req_cancel_subs (aio_req grp)
613{ 707{
614 aio_req sub;
615
616 if (grp->type != EIO_GROUP) 708 if (grp->type != EIO_GROUP)
617 return; 709 return;
618 710
619 SvREFCNT_dec (grp->sv2); 711 SvREFCNT_dec (grp->sv2);
620 grp->sv2 = 0; 712 grp->sv2 = 0;
621 713
622 eio_grp_cancel (grp); 714 eio_grp_cancel (grp);
623} 715}
624 716
625static void 717static void ecb_cold
626create_respipe (void) 718create_respipe (void)
627{ 719{
628 if (s_epipe_renew (&respipe)) 720 if (s_epipe_renew (&respipe))
629 croak ("IO::AIO: unable to initialize result pipe"); 721 croak ("IO::AIO: unable to initialize result pipe");
630} 722}
631 723
632static void poll_wait (void) 724static void
725poll_wait (void)
633{ 726{
634 while (eio_nreqs ()) 727 while (eio_nreqs ())
635 { 728 {
636 int size; 729 int size;
637 730
646 739
647 s_epipe_wait (&respipe); 740 s_epipe_wait (&respipe);
648 } 741 }
649} 742}
650 743
651static int poll_cb (void) 744static int
745poll_cb (void)
652{ 746{
653 for (;;) 747 for (;;)
654 { 748 {
655 int res = eio_poll (); 749 int res = eio_poll ();
656 750
662 756
663 poll_wait (); 757 poll_wait ();
664 } 758 }
665} 759}
666 760
667static void atfork_child (void) 761static void ecb_cold
762reinit (void)
668{ 763{
669 create_respipe (); 764 create_respipe ();
765
766 if (eio_init (want_poll, done_poll) < 0)
767 croak ("IO::AIO: unable to initialise eio library");
670} 768}
671 769
672/*****************************************************************************/ 770/*****************************************************************************/
673 771
674#if !_POSIX_MAPPED_FILES 772#if !_POSIX_MAPPED_FILES
685# define MAP_FIXED 0 783# define MAP_FIXED 0
686#endif 784#endif
687 785
688#define MMAP_MAGIC PERL_MAGIC_ext 786#define MMAP_MAGIC PERL_MAGIC_ext
689 787
690static int 788static int ecb_cold
691mmap_free (pTHX_ SV *sv, MAGIC *mg) 789mmap_free (pTHX_ SV *sv, MAGIC *mg)
692{ 790{
693 int old_errno = errno; 791 int old_errno = errno;
694 munmap (mg->mg_ptr, (size_t)mg->mg_obj); 792 munmap (mg->mg_ptr, (size_t)mg->mg_obj);
695 errno = old_errno; 793 errno = old_errno;
719{ 817{
720 SvGETMAGIC (cb_sv); 818 SvGETMAGIC (cb_sv);
721 return SvOK (cb_sv) ? s_get_cv_croak (cb_sv) : 0; 819 return SvOK (cb_sv) ? s_get_cv_croak (cb_sv) : 0;
722} 820}
723 821
822static aio_req ecb_noinline
823dreq (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
724#define dREQ \ 842#define dREQ \
725 SV *cb_cv; \ 843 aio_req req = dreq (callback); \
726 aio_req req; \
727 int req_pri = next_pri; \
728 next_pri = EIO_PRI_DEFAULT; \
729 \
730 cb_cv = get_cb (callback); \
731 \
732 Newz (0, req, 1, eio_req); \
733 if (!req) \
734 croak ("out of memory during eio_req allocation"); \
735 \
736 req->callback = SvREFCNT_inc (cb_cv); \
737 req->pri = req_pri
738 844
739#define REQ_SEND \ 845#define REQ_SEND \
740 PUTBACK; \ 846 PUTBACK; \
741 req_submit (req); \ 847 req_submit (req); \
742 SPAGAIN; \ 848 SPAGAIN; \
743 \ 849 \
744 if (GIMME_V != G_VOID) \ 850 if (GIMME_V != G_VOID) \
745 XPUSHs (req_sv (req, aio_req_stash)); 851 XPUSHs (req_sv (req, aio_req_stash));
852
853ecb_inline void
854req_set_path (aio_req req, SV *path, SV **wdsv, SV **pathsv, eio_wd *wd, void **ptr)
855{
856 if (expect_false (SvROK (path)))
857 {
858 SV *rv = SvRV (path);
859 SV *wdob;
860
861 if (SvTYPE (rv) == SVt_PVAV && AvFILLp (rv) == 1)
862 {
863 path = AvARRAY (rv)[1];
864 wdob = AvARRAY (rv)[0];
865
866 if (SvOK (wdob))
867 {
868 *wd = SvAIO_WD (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 "." */
880 }
881 else
882 croak ("IO::AIO: pathname arguments must be specified as a string, an IO::AIO::WD object or a [IO::AIO::WD, path] pair");
883 }
884
885 *pathsv = newSVsv (path);
886 *ptr = SvPVbyte_nolen (*pathsv);
887}
888
889static void ecb_noinline
890req_set_path1 (aio_req req, SV *path)
891{
892 req_set_path (req, path, &req->sv1, &req->sv3, &req->wd, &req->ptr1);
893}
894
895static void ecb_noinline
896req_set_fh_or_path (aio_req req, int type_path, int type_fh, SV *fh_or_path)
897{
898 SV *rv = SvROK (fh_or_path) ? SvRV (fh_or_path) : fh_or_path;
899
900 switch (SvTYPE (rv))
901 {
902 case SVt_PVIO:
903 case SVt_PVLV:
904 case SVt_PVGV:
905 req->type = type_fh;
906 req->sv1 = newSVsv (fh_or_path);
907 req->int1 = PerlIO_fileno (IoIFP (sv_2io (fh_or_path)));
908 break;
909
910 default:
911 req->type = type_path;
912 req_set_path1 (req, fh_or_path);
913 break;
914 }
915}
916
917XS(boot_IO__AIO) ecb_cold;
746 918
747MODULE = IO::AIO PACKAGE = IO::AIO 919MODULE = IO::AIO PACKAGE = IO::AIO
748 920
749PROTOTYPES: ENABLE 921PROTOTYPES: ENABLE
750 922
765 const_iv (O_CREAT) 937 const_iv (O_CREAT)
766 const_iv (O_TRUNC) 938 const_iv (O_TRUNC)
767 const_iv (O_EXCL) 939 const_iv (O_EXCL)
768 const_iv (O_APPEND) 940 const_iv (O_APPEND)
769 941
942 const_iv (O_ASYNC)
943 const_iv (O_DIRECT)
944 const_iv (O_NOATIME)
945
946 const_iv (O_CLOEXEC)
947 const_iv (O_NOCTTY)
948 const_iv (O_NOFOLLOW)
949 const_iv (O_NONBLOCK)
950 const_iv (O_EXEC)
951 const_iv (O_SEARCH)
952 const_iv (O_DIRECTORY)
953 const_iv (O_DSYNC)
954 const_iv (O_RSYNC)
955 const_iv (O_SYNC)
956 const_iv (O_TTY_INIT)
957
770 const_iv (S_IFIFO) 958 const_iv (S_IFIFO)
771 const_iv (S_IFCHR) 959 const_iv (S_IFCHR)
772 const_iv (S_IFBLK) 960 const_iv (S_IFBLK)
773 const_iv (S_IFLNK) 961 const_iv (S_IFLNK)
774 const_iv (S_IFREG) 962 const_iv (S_IFREG)
818 const_iv (MAP_LOCKED) 1006 const_iv (MAP_LOCKED)
819 const_iv (MAP_NORESERVE) 1007 const_iv (MAP_NORESERVE)
820 const_iv (MAP_POPULATE) 1008 const_iv (MAP_POPULATE)
821 const_iv (MAP_NONBLOCK) 1009 const_iv (MAP_NONBLOCK)
822 1010
1011 const_eio (SEEK_SET)
1012 const_eio (SEEK_CUR)
1013 const_eio (SEEK_END)
1014
823 const_eio (MCL_FUTURE) 1015 const_eio (MCL_FUTURE)
824 const_eio (MCL_CURRENT) 1016 const_eio (MCL_CURRENT)
825 1017
826 const_eio (MS_ASYNC) 1018 const_eio (MS_ASYNC)
827 const_eio (MS_INVALIDATE) 1019 const_eio (MS_INVALIDATE)
830 const_eio (MT_MODIFY) 1022 const_eio (MT_MODIFY)
831 1023
832 const_eio (SYNC_FILE_RANGE_WAIT_BEFORE) 1024 const_eio (SYNC_FILE_RANGE_WAIT_BEFORE)
833 const_eio (SYNC_FILE_RANGE_WRITE) 1025 const_eio (SYNC_FILE_RANGE_WRITE)
834 const_eio (SYNC_FILE_RANGE_WAIT_AFTER) 1026 const_eio (SYNC_FILE_RANGE_WAIT_AFTER)
1027
1028 const_eio (FALLOC_FL_KEEP_SIZE)
835 1029
836 const_eio (READDIR_DENTS) 1030 const_eio (READDIR_DENTS)
837 const_eio (READDIR_DIRS_FIRST) 1031 const_eio (READDIR_DIRS_FIRST)
838 const_eio (READDIR_STAT_ORDER) 1032 const_eio (READDIR_STAT_ORDER)
839 const_eio (READDIR_FOUND_UNKNOWN) 1033 const_eio (READDIR_FOUND_UNKNOWN)
850 }; 1044 };
851 1045
852 aio_stash = gv_stashpv ("IO::AIO" , 1); 1046 aio_stash = gv_stashpv ("IO::AIO" , 1);
853 aio_req_stash = gv_stashpv ("IO::AIO::REQ", 1); 1047 aio_req_stash = gv_stashpv ("IO::AIO::REQ", 1);
854 aio_grp_stash = gv_stashpv ("IO::AIO::GRP", 1); 1048 aio_grp_stash = gv_stashpv ("IO::AIO::GRP", 1);
1049 aio_wd_stash = gv_stashpv ("IO::AIO::WD" , 1);
855 1050
856 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 1051 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--)
857 newCONSTSUB (aio_stash, (char *)civ->name, newSViv (civ->iv)); 1052 newCONSTSUB (aio_stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
858 1053
859 newCONSTSUB (aio_stash, "PAGESIZE", newSViv (PAGESIZE)); 1054 newCONSTSUB (aio_stash, "PAGESIZE", newSViv (PAGESIZE));
860 1055
861 create_respipe (); 1056 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} 1057}
869 1058
870void 1059void
1060reinit ()
1061 PROTOTYPE:
1062
1063void
871max_poll_reqs (int nreqs) 1064max_poll_reqs (unsigned int nreqs)
872 PROTOTYPE: $ 1065 PROTOTYPE: $
873 CODE: 1066 CODE:
874 eio_set_max_poll_reqs (nreqs); 1067 eio_set_max_poll_reqs (nreqs);
875 1068
876void 1069void
878 PROTOTYPE: $ 1071 PROTOTYPE: $
879 CODE: 1072 CODE:
880 eio_set_max_poll_time (nseconds); 1073 eio_set_max_poll_time (nseconds);
881 1074
882void 1075void
883min_parallel (int nthreads) 1076min_parallel (unsigned int nthreads)
884 PROTOTYPE: $ 1077 PROTOTYPE: $
885 CODE: 1078 CODE:
886 eio_set_min_parallel (nthreads); 1079 eio_set_min_parallel (nthreads);
887 1080
888void 1081void
889max_parallel (int nthreads) 1082max_parallel (unsigned int nthreads)
890 PROTOTYPE: $ 1083 PROTOTYPE: $
891 CODE: 1084 CODE:
892 eio_set_max_parallel (nthreads); 1085 eio_set_max_parallel (nthreads);
893 1086
894void 1087void
895max_idle (int nthreads) 1088max_idle (unsigned int nthreads)
896 PROTOTYPE: $ 1089 PROTOTYPE: $
897 CODE: 1090 CODE:
898 eio_set_max_idle (nthreads); 1091 eio_set_max_idle (nthreads);
899 1092
900void 1093void
1094idle_timeout (unsigned int seconds)
1095 PROTOTYPE: $
1096 CODE:
1097 eio_set_idle_timeout (seconds);
1098
1099void
901max_outstanding (int maxreqs) 1100max_outstanding (unsigned int maxreqs)
902 PROTOTYPE: $ 1101 PROTOTYPE: $
903 CODE: 1102 CODE:
904 max_outstanding = maxreqs; 1103 max_outstanding = maxreqs;
905 1104
906void 1105void
1106aio_wd (SV8 *pathname, SV *callback=&PL_sv_undef)
1107 PPCODE:
1108{
1109 dREQ;
1110
1111 req->type = EIO_WD_OPEN;
1112 req_set_path1 (req, pathname);
1113
1114 REQ_SEND;
1115}
1116
1117void
907aio_open (SV8 *pathname, int flags, int mode, SV *callback=&PL_sv_undef) 1118aio_open (SV8 *pathname, int flags, int mode, SV *callback=&PL_sv_undef)
908 PPCODE: 1119 PPCODE:
909{ 1120{
910 dREQ; 1121 dREQ;
911 1122
912 req->type = EIO_OPEN; 1123 req->type = EIO_OPEN;
913 req->sv1 = newSVsv (pathname); 1124 req_set_path1 (req, pathname);
914 req->ptr1 = SvPVbyte_nolen (req->sv1);
915 req->int1 = flags; 1125 req->int1 = flags;
916 req->int2 = mode; 1126 req->int2 = mode;
917 1127
918 REQ_SEND; 1128 REQ_SEND;
919} 1129}
921void 1131void
922aio_fsync (SV *fh, SV *callback=&PL_sv_undef) 1132aio_fsync (SV *fh, SV *callback=&PL_sv_undef)
923 ALIAS: 1133 ALIAS:
924 aio_fsync = EIO_FSYNC 1134 aio_fsync = EIO_FSYNC
925 aio_fdatasync = EIO_FDATASYNC 1135 aio_fdatasync = EIO_FDATASYNC
1136 aio_syncfs = EIO_SYNCFS
926 PPCODE: 1137 PPCODE:
927{ 1138{
928 int fd = s_fileno_croak (fh, 0); 1139 int fd = s_fileno_croak (fh, 0);
929 dREQ; 1140 dREQ;
930 1141
931 req->type = ix; 1142 req->type = ix;
932 req->sv1 = newSVsv (fh); 1143 req->sv1 = newSVsv (fh);
933 req->int1 = fd; 1144 req->int1 = fd;
934 1145
935 REQ_SEND (req); 1146 REQ_SEND;
936} 1147}
937 1148
938void 1149void
939aio_sync_file_range (SV *fh, off_t offset, size_t nbytes, UV flags, SV *callback=&PL_sv_undef) 1150aio_sync_file_range (SV *fh, off_t offset, size_t nbytes, UV flags, SV *callback=&PL_sv_undef)
940 PPCODE: 1151 PPCODE:
947 req->int1 = fd; 1158 req->int1 = fd;
948 req->offs = offset; 1159 req->offs = offset;
949 req->size = nbytes; 1160 req->size = nbytes;
950 req->int2 = flags; 1161 req->int2 = flags;
951 1162
952 REQ_SEND (req); 1163 REQ_SEND;
1164}
1165
1166void
1167aio_fallocate (SV *fh, int mode, off_t offset, size_t len, SV *callback=&PL_sv_undef)
1168 PPCODE:
1169{
1170 int fd = s_fileno_croak (fh, 0);
1171 dREQ;
1172
1173 req->type = EIO_FALLOCATE;
1174 req->sv1 = newSVsv (fh);
1175 req->int1 = fd;
1176 req->int2 = mode;
1177 req->offs = offset;
1178 req->size = len;
1179
1180 REQ_SEND;
953} 1181}
954 1182
955void 1183void
956aio_close (SV *fh, SV *callback=&PL_sv_undef) 1184aio_close (SV *fh, SV *callback=&PL_sv_undef)
957 PPCODE: 1185 PPCODE:
958{ 1186{
959 static int close_pipe = -1; /* dummy fd to close fds via dup2 */ 1187 static int close_fd = -1; /* dummy fd to close fds via dup2 */
960 int fd = s_fileno_croak (fh, 0); 1188 int fd = s_fileno_croak (fh, 0);
961 dREQ; 1189 dREQ;
962 1190
963 if (close_pipe < 0) 1191 if (expect_false (close_fd < 0))
964 { 1192 {
965 int pipefd [2]; 1193 int pipefd [2];
966 1194
1195 if (
1196#ifdef _WIN32
1197 _pipe (pipefd, 1, _O_BINARY) < 0
1198#else
967 if (pipe (pipefd) < 0 1199 pipe (pipefd) < 0
968 || close (pipefd [1]) < 0
969 || fcntl (pipefd [0], F_SETFD, FD_CLOEXEC) < 0) 1200 || fcntl (pipefd [0], F_SETFD, FD_CLOEXEC) < 0
1201#endif
1202 || close (pipefd [1]) < 0
1203 )
970 abort (); /*D*/ 1204 abort (); /*D*/
971 1205
972 close_pipe = pipefd [0]; 1206 close_fd = pipefd [0];
973 } 1207 }
974 1208
975 req->type = EIO_DUP2; 1209 req->type = EIO_DUP2;
976 req->int1 = close_pipe; 1210 req->int1 = close_fd;
977 req->sv2 = newSVsv (fh); 1211 req->sv2 = newSVsv (fh);
978 req->int2 = fd; 1212 req->int2 = fd;
979 1213
980 REQ_SEND (req); 1214 REQ_SEND;
1215}
1216
1217void
1218aio_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;
981} 1232}
982 1233
983void 1234void
984aio_read (SV *fh, SV *offset, SV *length, SV8 *data, IV dataoffset, SV *callback=&PL_sv_undef) 1235aio_read (SV *fh, SV *offset, SV *length, SV8 *data, IV dataoffset, SV *callback=&PL_sv_undef)
985 ALIAS: 1236 ALIAS:
1032 REQ_SEND; 1283 REQ_SEND;
1033 } 1284 }
1034} 1285}
1035 1286
1036void 1287void
1037aio_readlink (SV8 *path, SV *callback=&PL_sv_undef) 1288aio_readlink (SV8 *pathname, SV *callback=&PL_sv_undef)
1289 ALIAS:
1290 aio_readlink = EIO_READLINK
1291 aio_realpath = EIO_REALPATH
1038 PPCODE: 1292 PPCODE:
1039{ 1293{
1040 SV *data;
1041 dREQ; 1294 dREQ;
1042 1295
1043 req->type = EIO_READLINK; 1296 req->type = ix;
1044 req->sv1 = newSVsv (path); 1297 req_set_path1 (req, pathname);
1045 req->ptr1 = SvPVbyte_nolen (req->sv1);
1046 1298
1047 REQ_SEND; 1299 REQ_SEND;
1048} 1300}
1049 1301
1050void 1302void
1090 aio_statvfs = EIO_STATVFS 1342 aio_statvfs = EIO_STATVFS
1091 PPCODE: 1343 PPCODE:
1092{ 1344{
1093 dREQ; 1345 dREQ;
1094 1346
1095 req->sv1 = newSVsv (fh_or_path); 1347 req_set_fh_or_path (req, ix, ix == EIO_STATVFS ? EIO_FSTATVFS : EIO_FSTAT, fh_or_path);
1096
1097 if (SvPOK (req->sv1))
1098 {
1099 req->type = ix;
1100 req->ptr1 = SvPVbyte_nolen (req->sv1);
1101 }
1102 else
1103 {
1104 req->type = ix == EIO_STATVFS ? EIO_FSTATVFS : EIO_FSTAT;
1105 req->int1 = PerlIO_fileno (IoIFP (sv_2io (fh_or_path)));
1106 }
1107 1348
1108 REQ_SEND; 1349 REQ_SEND;
1109} 1350}
1110 1351
1111UV 1352UV
1130{ 1371{
1131 dREQ; 1372 dREQ;
1132 1373
1133 req->nv1 = SvOK (atime) ? SvNV (atime) : -1.; 1374 req->nv1 = SvOK (atime) ? SvNV (atime) : -1.;
1134 req->nv2 = SvOK (mtime) ? SvNV (mtime) : -1.; 1375 req->nv2 = SvOK (mtime) ? SvNV (mtime) : -1.;
1135 req->sv1 = newSVsv (fh_or_path); 1376 req_set_fh_or_path (req, EIO_UTIME, EIO_FUTIME, fh_or_path);
1136
1137 if (SvPOK (req->sv1))
1138 {
1139 req->type = EIO_UTIME;
1140 req->ptr1 = SvPVbyte_nolen (req->sv1);
1141 }
1142 else
1143 {
1144 req->type = EIO_FUTIME;
1145 req->int1 = PerlIO_fileno (IoIFP (sv_2io (fh_or_path)));
1146 }
1147 1377
1148 REQ_SEND; 1378 REQ_SEND;
1149} 1379}
1150 1380
1151void 1381void
1152aio_truncate (SV8 *fh_or_path, SV *offset, SV *callback=&PL_sv_undef) 1382aio_truncate (SV8 *fh_or_path, SV *offset, SV *callback=&PL_sv_undef)
1153 PPCODE: 1383 PPCODE:
1154{ 1384{
1155 dREQ; 1385 dREQ;
1156 1386
1157 req->sv1 = newSVsv (fh_or_path);
1158 req->offs = SvOK (offset) ? SvVAL64 (offset) : -1; 1387 req->offs = SvOK (offset) ? SvVAL64 (offset) : -1;
1159 1388 req_set_fh_or_path (req, EIO_TRUNCATE, EIO_FTRUNCATE, fh_or_path);
1160 if (SvPOK (req->sv1))
1161 {
1162 req->type = EIO_TRUNCATE;
1163 req->ptr1 = SvPVbyte_nolen (req->sv1);
1164 }
1165 else
1166 {
1167 req->type = EIO_FTRUNCATE;
1168 req->int1 = PerlIO_fileno (IoIFP (sv_2io (fh_or_path)));
1169 }
1170 1389
1171 REQ_SEND; 1390 REQ_SEND;
1172} 1391}
1173 1392
1174void 1393void
1175aio_chmod (SV8 *fh_or_path, int mode, SV *callback=&PL_sv_undef) 1394aio_chmod (SV8 *fh_or_path, int mode, SV *callback=&PL_sv_undef)
1176 ALIAS:
1177 aio_chmod = EIO_CHMOD
1178 aio_mkdir = EIO_MKDIR
1179 PPCODE: 1395 PPCODE:
1180{ 1396{
1181 dREQ; 1397 dREQ;
1182 1398
1183 req->int2 = mode; 1399 req->int2 = mode;
1184 req->sv1 = newSVsv (fh_or_path); 1400 req_set_fh_or_path (req, EIO_CHMOD, EIO_FCHMOD, fh_or_path);
1185
1186 if (SvPOK (req->sv1))
1187 {
1188 req->type = ix;
1189 req->ptr1 = SvPVbyte_nolen (req->sv1);
1190 }
1191 else
1192 {
1193 req->type = EIO_FCHMOD;
1194 req->int1 = PerlIO_fileno (IoIFP (sv_2io (fh_or_path)));
1195 }
1196 1401
1197 REQ_SEND; 1402 REQ_SEND;
1198} 1403}
1199 1404
1200void 1405void
1203{ 1408{
1204 dREQ; 1409 dREQ;
1205 1410
1206 req->int2 = SvOK (uid) ? SvIV (uid) : -1; 1411 req->int2 = SvOK (uid) ? SvIV (uid) : -1;
1207 req->int3 = SvOK (gid) ? SvIV (gid) : -1; 1412 req->int3 = SvOK (gid) ? SvIV (gid) : -1;
1208 req->sv1 = newSVsv (fh_or_path); 1413 req_set_fh_or_path (req, EIO_CHOWN, EIO_FCHOWN, fh_or_path);
1209
1210 if (SvPOK (req->sv1))
1211 {
1212 req->type = EIO_CHOWN;
1213 req->ptr1 = SvPVbyte_nolen (req->sv1);
1214 }
1215 else
1216 {
1217 req->type = EIO_FCHOWN;
1218 req->int1 = PerlIO_fileno (IoIFP (sv_2io (fh_or_path)));
1219 }
1220 1414
1221 REQ_SEND; 1415 REQ_SEND;
1222} 1416}
1223 1417
1224void 1418void
1226 PPCODE: 1420 PPCODE:
1227{ 1421{
1228 dREQ; 1422 dREQ;
1229 1423
1230 req->type = EIO_READDIR; 1424 req->type = EIO_READDIR;
1231 req->sv1 = newSVsv (pathname);
1232 req->ptr1 = SvPVbyte_nolen (req->sv1);
1233 req->int1 = flags | EIO_READDIR_DENTS | EIO_READDIR_CUSTOM1; 1425 req->int1 = flags | EIO_READDIR_DENTS | EIO_READDIR_CUSTOM1;
1234 1426
1235 if (flags & EIO_READDIR_DENTS) 1427 if (flags & EIO_READDIR_DENTS)
1236 req->int1 |= EIO_READDIR_CUSTOM2; 1428 req->int1 |= EIO_READDIR_CUSTOM2;
1237 1429
1430 req_set_path1 (req, pathname);
1431
1238 REQ_SEND; 1432 REQ_SEND;
1433}
1434
1435void
1436aio_mkdir (SV8 *pathname, int mode, SV *callback=&PL_sv_undef)
1437 PPCODE:
1438{
1439 dREQ;
1440
1441 req->type = EIO_MKDIR;
1442 req->int2 = mode;
1443 req_set_path1 (req, pathname);
1444
1445 REQ_SEND;
1239} 1446}
1240 1447
1241void 1448void
1242aio_unlink (SV8 *pathname, SV *callback=&PL_sv_undef) 1449aio_unlink (SV8 *pathname, SV *callback=&PL_sv_undef)
1243 ALIAS: 1450 ALIAS:
1247 PPCODE: 1454 PPCODE:
1248{ 1455{
1249 dREQ; 1456 dREQ;
1250 1457
1251 req->type = ix; 1458 req->type = ix;
1252 req->sv1 = newSVsv (pathname); 1459 req_set_path1 (req, pathname);
1253 req->ptr1 = SvPVbyte_nolen (req->sv1);
1254 1460
1255 REQ_SEND; 1461 REQ_SEND;
1256} 1462}
1257 1463
1258void 1464void
1261 aio_link = EIO_LINK 1467 aio_link = EIO_LINK
1262 aio_symlink = EIO_SYMLINK 1468 aio_symlink = EIO_SYMLINK
1263 aio_rename = EIO_RENAME 1469 aio_rename = EIO_RENAME
1264 PPCODE: 1470 PPCODE:
1265{ 1471{
1472 eio_wd wd2 = 0;
1266 dREQ; 1473 dREQ;
1267 1474
1268 req->type = ix; 1475 req->type = ix;
1269 req->sv1 = newSVsv (oldpath); 1476 req_set_path1 (req, oldpath);
1270 req->ptr1 = SvPVbyte_nolen (req->sv1); 1477 req_set_path (req, newpath, &req->sv2, &req->sv4, &wd2, &req->ptr2);
1271 req->sv2 = newSVsv (newpath); 1478 req->int3 = (long)wd2;
1272 req->ptr2 = SvPVbyte_nolen (req->sv2);
1273 1479
1274 REQ_SEND; 1480 REQ_SEND;
1275} 1481}
1276 1482
1277void 1483void
1279 PPCODE: 1485 PPCODE:
1280{ 1486{
1281 dREQ; 1487 dREQ;
1282 1488
1283 req->type = EIO_MKNOD; 1489 req->type = EIO_MKNOD;
1284 req->sv1 = newSVsv (pathname);
1285 req->ptr1 = SvPVbyte_nolen (req->sv1);
1286 req->int2 = (mode_t)mode; 1490 req->int2 = (mode_t)mode;
1287 req->offs = dev; 1491 req->offs = dev;
1492 req_set_path1 (req, pathname);
1288 1493
1289 REQ_SEND; 1494 REQ_SEND;
1290} 1495}
1291 1496
1292void 1497void
1492 CODE: 1697 CODE:
1493 RETVAL = posix_fadvise (fh, offset, length, advice); 1698 RETVAL = posix_fadvise (fh, offset, length, advice);
1494 OUTPUT: 1699 OUTPUT:
1495 RETVAL 1700 RETVAL
1496 1701
1497ssize_t 1702IV
1498sendfile (aio_wfd ofh, aio_rfd ifh, off_t offset, size_t count) 1703sendfile (aio_wfd ofh, aio_rfd ifh, off_t offset, size_t count)
1499 CODE: 1704 CODE:
1500 RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); 1705 RETVAL = eio_sendfile_sync (ofh, ifh, offset, count);
1501 OUTPUT: 1706 OUTPUT:
1502 RETVAL 1707 RETVAL
1614 SvREFCNT_dec (on_next_submit); 1819 SvREFCNT_dec (on_next_submit);
1615 on_next_submit = SvOK (cb) ? newSVsv (cb) : 0; 1820 on_next_submit = SvOK (cb) ? newSVsv (cb) : 0;
1616 1821
1617PROTOTYPES: DISABLE 1822PROTOTYPES: DISABLE
1618 1823
1824MODULE = IO::AIO PACKAGE = IO::AIO::WD
1825
1826BOOT:
1827{
1828 newCONSTSUB (aio_stash, "CWD" , newSVaio_wd (EIO_CWD ));
1829 newCONSTSUB (aio_stash, "INVALID_WD", newSVaio_wd (EIO_INVALID_WD));
1830}
1831
1832void
1833DESTROY (SV *self)
1834 CODE:
1835{
1836 aio_wd wd = SvAIO_WD (self);
1837#if HAVE_AT
1838 {
1839 SV *callback = &PL_sv_undef;
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 */
1843 req->type = EIO_WD_CLOSE;
1844 req->wd = wd;
1845 REQ_SEND;
1846 }
1847#else
1848 eio_wd_close_sync (wd);
1849#endif
1850}
1851
1619MODULE = IO::AIO PACKAGE = IO::AIO::REQ 1852MODULE = IO::AIO PACKAGE = IO::AIO::REQ
1620 1853
1621void 1854void
1622cancel (aio_req_ornot req) 1855cancel (aio_req_ornot req)
1623 CODE: 1856 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines