--- IO-AIO/AIO.xs 2011/09/29 10:01:35 1.202 +++ IO-AIO/AIO.xs 2012/08/24 15:33:40 1.222 @@ -21,6 +21,15 @@ # include #endif +#if __linux__ +# include +# ifdef FS_IOC_FIEMAP +# include +# include +# define HAVE_FIEMAP 1 +# endif +#endif + /* perl namespace pollution */ #undef VERSION @@ -64,6 +73,9 @@ #undef abort #undef pipe + #define EIO_STRUCT_STAT struct _stati64 + #define EIO_STRUCT_STATI64 + #else #include @@ -72,19 +84,8 @@ #include #include -#endif - -#define EIO_STRUCT_STAT Stat_t + #define EIO_STRUCT_STAT Stat_t -/* use NV for 32 bit perls as it allows larger offsets */ -#if IVSIZE >= 8 -# define VAL64 IV -# define SvVAL64 SvIV -# define newSVval64 newSViv -#else -# define VAL64 NV -# define SvVAL64 SvNV -# define newSVval64 newSVnv #endif /*****************************************************************************/ @@ -125,170 +126,14 @@ #include "libeio/eio.c" -/* Linux/others */ -#ifndef O_ASYNC -# define O_ASYNC 0 -#endif -#ifndef O_DIRECT -# define O_DIRECT 0 -#endif -#ifndef O_NOATIME -# define O_NOATIME 0 -#endif - -/* POSIX */ -#ifndef O_CLOEXEC -# define O_CLOEXEC 0 -#endif -#ifndef O_NOFOLLOW -# define O_NOFOLLOW 0 -#endif -#ifndef O_NOCTTY -# define O_NOCTTY 0 -#endif -#ifndef O_NONBLOCK -# define O_NONBLOCK 0 -#endif -#ifndef O_EXEC -# define O_EXEC 0 -#endif -#ifndef O_SEARCH -# define O_SEARCH 0 -#endif -#ifndef O_DIRECTORY -# define O_DIRECTORY 0 -#endif -#ifndef O_DSYNC -# define O_DSYNC 0 -#endif -#ifndef O_RSYNC -# define O_RSYNC 0 -#endif -#ifndef O_SYNC -# define O_SYNC 0 -#endif -#ifndef O_TTY_INIT -# define O_TTY_INIT 0 -#endif - -#ifndef POSIX_FADV_NORMAL -# define POSIX_FADV_NORMAL 0 -#endif -#ifndef POSIX_FADV_SEQUENTIAL -# define POSIX_FADV_SEQUENTIAL 0 -#endif -#ifndef POSIX_FADV_RANDOM -# define POSIX_FADV_RANDOM 0 -#endif -#ifndef POSIX_FADV_NOREUSE -# define POSIX_FADV_NOREUSE 0 -#endif -#ifndef POSIX_FADV_WILLNEED -# define POSIX_FADV_WILLNEED 0 -#endif -#ifndef POSIX_FADV_DONTNEED -# define POSIX_FADV_DONTNEED 0 -#endif - #if !HAVE_POSIX_FADVISE # define posix_fadvise(a,b,c,d) errno = ENOSYS /* also return ENOSYS */ #endif -#ifndef POSIX_MADV_NORMAL -# define POSIX_MADV_NORMAL 0 -#endif -#ifndef POSIX_MADV_SEQUENTIAL -# define POSIX_MADV_SEQUENTIAL 0 -#endif -#ifndef POSIX_MADV_RANDOM -# define POSIX_MADV_RANDOM 0 -#endif -#ifndef POSIX_MADV_WILLNEED -# define POSIX_MADV_WILLNEED 0 -#endif -#ifndef POSIX_MADV_DONTNEED -# define POSIX_MADV_DONTNEED 0 -#endif - #if !HAVE_POSIX_MADVISE # define posix_madvise(a,b,c) errno = ENOSYS /* also return ENOSYS */ #endif -#ifndef PROT_NONE -# define PROT_NONE 0 -#endif -#ifndef PROT_READ -# define PROT_READ 0 -#endif -#ifndef PROT_WRITE -# define PROT_READ 0 -#endif -#ifndef PROT_EXEC -# define PROT_EXEC 0 -#endif - -#ifndef ST_RDONLY -# define ST_RDONLY 0 -#endif -#ifndef ST_NOSUID -# define ST_NOSUID 0 -#endif -#ifndef ST_NODEV -# define ST_NODEV 0 -#endif -#ifndef ST_NOEXEC -# define ST_NOEXEC 0 -#endif -#ifndef ST_SYNCHRONOUS -# define ST_SYNCHRONOUS 0 -#endif -#ifndef ST_MANDLOCK -# define ST_MANDLOCK 0 -#endif -#ifndef ST_WRITE -# define ST_WRITE 0 -#endif -#ifndef ST_APPEND -# define ST_APPEND 0 -#endif -#ifndef ST_IMMUTABLE -# define ST_IMMUTABLE 0 -#endif -#ifndef ST_NOATIME -# define ST_NOATIME 0 -#endif -#ifndef ST_NODIRATIME -# define ST_NODIRATIME 0 -#endif -#ifndef ST_RELATIME -# define ST_RELATIME 0 -#endif - -#ifndef S_IFIFO -# define S_IFIFO 0 -#endif -#ifndef S_IFCHR -# define S_IFCHR 0 -#endif -#ifndef S_IFBLK -# define S_IFBLK 0 -#endif -#ifndef S_IFLNK -# define S_IFLNK 0 -#endif -#ifndef S_IFREG -# define S_IFREG 0 -#endif -#ifndef S_IFDIR -# define S_IFDIR 0 -#endif -#ifndef S_IFWHT -# define S_IFWHT 0 -#endif -#ifndef S_IFSOCK -# define S_IFSOCK 0 -#endif - #ifndef MAP_ANONYMOUS # ifdef MAP_ANON # define MAP_ANONYMOUS MAP_ANON @@ -296,21 +141,9 @@ # define MAP_ANONYMOUS MAP_FIXED /* and hope this fails */ # endif #endif -#ifndef MAP_HUGETLB -# define MAP_HUGETLB 0 -#endif -#ifndef MAP_LOCKED -# define MAP_LOCKED 0 -#endif -#ifndef MAP_NORESERVE -# define MAP_NORESERVE 0 -#endif -#ifndef MAP_POPULATE -# define MAP_POPULATE 0 -#endif -#ifndef MAP_NONBLOCK -# define MAP_NONBLOCK 0 -#endif + +/* defines all sorts of constants to 0 unless they are already defined */ +#include "def0.h" #ifndef makedev # define makedev(maj,min) (((maj) << 8) | (min)) @@ -326,6 +159,103 @@ # define PAGESIZE sysconf (_SC_PAGESIZE) #endif +/*****************************************************************************/ + +static void +fiemap (eio_req *req) +{ + req->result = -1; + +#if HAVE_FIEMAP + /* assume some c99 */ + struct fiemap *fiemap = 0; + size_t end_offset; + int count = req->int3; + + req->flags |= EIO_FLAG_PTR1_FREE; + + /* heuristic: start with 512 bytes (8 extents), and if that isn't enough, */ + /* increase in 3.5kb steps */ + if (count < 0) + count = 8; + + fiemap = malloc (sizeof (*fiemap) + sizeof (struct fiemap_extent) * count); + errno = ENOMEM; + if (!fiemap) + return; + + req->ptr1 = fiemap; + + fiemap->fm_start = req->offs; + fiemap->fm_length = req->size; + fiemap->fm_flags = req->int2; + fiemap->fm_extent_count = count; + + if (ioctl (req->int1, FS_IOC_FIEMAP, fiemap)) + return; + + if (req->int3 >= 0 /* not autosizing */ + || !fiemap->fm_mapped_extents /* no more extents */ + || fiemap->fm_extents [fiemap->fm_mapped_extents - 1].fe_flags & FIEMAP_EXTENT_LAST /* hit eof */) + goto done; + + /* else we have to loop - + * it would be tempting (atcually I tried that first) to just query the + * number of extents needed, but linux often feels like not returning all + * extents, without telling us it left any out. this complicates + * this quite a bit. + */ + + end_offset = fiemap->fm_length + (fiemap->fm_length == FIEMAP_MAX_OFFSET ? 0 : fiemap->fm_start); + + for (;;) + { + /* we go in 54 extent steps - 3kb, in the hope that this fits nicely on the eio stack (normally 16+ kb) */ + char scratch[3072]; + struct fiemap *incmap = (struct fiemap *)scratch; + + incmap->fm_start = fiemap->fm_extents [fiemap->fm_mapped_extents - 1].fe_logical + + fiemap->fm_extents [fiemap->fm_mapped_extents - 1].fe_length; + incmap->fm_length = fiemap->fm_length - (incmap->fm_start - fiemap->fm_start); + incmap->fm_flags = fiemap->fm_flags; + incmap->fm_extent_count = (sizeof (scratch) - sizeof (struct fiemap)) / sizeof (struct fiemap_extent); + + if (ioctl (req->int1, FS_IOC_FIEMAP, incmap)) + return; + + count = fiemap->fm_mapped_extents + incmap->fm_mapped_extents; + fiemap = realloc (fiemap, sizeof (*fiemap) + sizeof (struct fiemap_extent) * count); + errno = ENOMEM; + if (!fiemap) + return; + + req->ptr1 = fiemap; + + for (count = 0; count < incmap->fm_mapped_extents; ++count) + { + struct fiemap_extent *e = incmap->fm_extents + count; + + if (e->fe_logical + e->fe_length >= end_offset) + goto done; + + fiemap->fm_extents [fiemap->fm_mapped_extents++] = *e; + + if (e->fe_flags & FIEMAP_EXTENT_LAST) + goto done; + + } + } + +done: + req->result = 0; + +#else + errno = ENOSYS; +#endif +} + +/*****************************************************************************/ + enum { FLAG_SV2_RO_OFF = 0x40, /* data was set readonly */ }; @@ -373,7 +303,7 @@ static SV * newSVaio_wd (aio_wd wd) { - return sv_bless (newRV_noinc (newSViv ((long)wd)), aio_wd_stash); + return sv_bless (newRV_noinc (newSViv ((IV)wd)), aio_wd_stash); } static aio_req @@ -382,6 +312,7 @@ MAGIC *mg; if (!SvROK (sv) + /* for speed reasons, we do not verify that SvROK actually has a stash ptr */ || (SvSTASH (SvRV (sv)) != aio_grp_stash && SvSTASH (SvRV (sv)) != aio_req_stash && !sv_derived_from (sv, "IO::AIO::REQ"))) @@ -396,8 +327,8 @@ SvAIO_WD (SV *sv) { if (!SvROK (sv) - || SvSTASH (SvRV (sv)) != aio_wd_stash - || SvTYPE (SvRV (sv)) != SVt_PVMG) + || SvTYPE (SvRV (sv)) != SVt_PVMG + || SvSTASH (SvRV (sv)) != aio_wd_stash) croak ("IO::AIO: expected a working directory object as returned by aio_wd"); return (aio_wd)(long)SvIVX (SvRV (sv)); @@ -473,7 +404,7 @@ switch (req->type) { case EIO_WD_OPEN: - PUSHs (sv_2mortal (newSVaio_wd (req->wd))); + PUSHs (req->result ? &PL_sv_undef : sv_2mortal (newSVaio_wd (req->wd))); break; case EIO_READDIR: @@ -636,6 +567,10 @@ PUSHs (sv_result); break; + case EIO_SEEK: + PUSHs (req->result ? sv_result : sv_2mortal (newSVval64 (req->offs))); + break; + case EIO_READ: { SvCUR_set (req->sv2, req->stroffset + (req->result > 0 ? req->result : 0)); @@ -646,6 +581,46 @@ } break; + case EIO_CUSTOM: + if (req->feed == fiemap) + { +#if HAVE_FIEMAP + if (!req->result) + { + struct fiemap *fiemap = (struct fiemap *)req->ptr1; + + if (fiemap->fm_extent_count) + { + AV *av = newAV (); + int i; + + while (fiemap->fm_mapped_extents) + { + struct fiemap_extent *extent = &fiemap->fm_extents [--fiemap->fm_mapped_extents]; + AV *ext_av = newAV (); + + av_store (ext_av, 3, newSVuv (extent->fe_flags)); + av_store (ext_av, 2, newSVval64 (extent->fe_length)); + av_store (ext_av, 1, newSVval64 (extent->fe_physical)); + av_store (ext_av, 0, newSVval64 (extent->fe_logical)); + + av_store (av, fiemap->fm_mapped_extents, newRV_noinc ((SV *)ext_av)); + } + + PUSHs (sv_2mortal (newRV_noinc ((SV *)av))); + } + else + { + SvIV_set (sv_result, fiemap->fm_mapped_extents); + PUSHs (sv_result); + } + } +#endif + } + else + PUSHs (sv_result); + break; + case EIO_DUP2: /* EIO_DUP2 actually means aio_close(), so fudge result value */ if (req->result > 0) SvIV_set (sv_result, 0); @@ -691,7 +666,7 @@ SvREFCNT_dec (req->sv4); SvREFCNT_dec (req->callback); - Safefree (req); + free (req); } static void @@ -762,12 +737,12 @@ /*****************************************************************************/ #if !_POSIX_MAPPED_FILES -# define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, -1) -# define munmap(addr,length) (errno = ENOSYS, -1) +# define mmap(addr,length,prot,flags,fd,offs) EIO_ENOSYS () +# define munmap(addr,length) EIO_ENOSYS () #endif #if !_POSIX_MEMORY_PROTECTION -# define mprotect(addr,len,prot) (errno = ENOSYS, -1) +# define mprotect(addr,len,prot) EIO_ENOSYS () # define PROT_NONE 0 # define PROT_WRITE 0 # define MAP_PRIVATE 0 @@ -811,20 +786,28 @@ return SvOK (cb_sv) ? s_get_cv_croak (cb_sv) : 0; } +static aio_req ecb_noinline +dreq (SV *callback) +{ + SV *cb_cv; + aio_req req; + int req_pri = next_pri; + next_pri = EIO_PRI_DEFAULT; + + cb_cv = get_cb (callback); + + req = calloc (sizeof (*req), 1); + if (!req) + croak ("out of memory during eio_req allocation"); + + req->callback = SvREFCNT_inc (cb_cv); + req->pri = req_pri; + + return req; +} + #define dREQ \ - SV *cb_cv; \ - aio_req req; \ - int req_pri = next_pri; \ - next_pri = EIO_PRI_DEFAULT; \ - \ - cb_cv = get_cb (callback); \ - \ - Newz (0, req, 1, eio_req); \ - if (!req) \ - croak ("out of memory during eio_req allocation"); \ - \ - req->callback = SvREFCNT_inc (cb_cv); \ - req->pri = req_pri + aio_req req = dreq (callback); \ #define REQ_SEND \ PUTBACK; \ @@ -839,22 +822,31 @@ { if (expect_false (SvROK (path))) { - AV *av = (AV *)SvRV (path); + SV *rv = SvRV (path); SV *wdob; - if (SvTYPE (av) != SVt_PVAV || AvFILLp (av) != 1) - croak ("IO::AIO: pathname arguments must be specified as strings or [wd, path] arrayrefs"); - - path = AvARRAY (av)[1]; - wdob = AvARRAY (av)[0]; + if (SvTYPE (rv) == SVt_PVAV && AvFILLp (rv) == 1) + { + path = AvARRAY (rv)[1]; + wdob = AvARRAY (rv)[0]; - if (SvOK (wdob)) + if (SvOK (wdob)) + { + *wd = SvAIO_WD (wdob); + *wdsv = SvREFCNT_inc_NN (SvRV (wdob)); + } + else + *wd = EIO_INVALID_WD; + } + else if (SvTYPE (rv) == SVt_PVMG && SvSTASH (rv) == aio_wd_stash) { - *wd = SvAIO_WD (wdob); - *wdsv = SvREFCNT_inc_NN (SvRV (wdob)); + *wd = (aio_wd)(long)SvIVX (rv); + *wdsv = SvREFCNT_inc_NN (rv); + *ptr = "."; + return; /* path set to "." */ } else - *wd = EIO_INVALID_WD; + croak ("IO::AIO: pathname arguments must be specified as a string, an IO::AIO::WD object or a [IO::AIO::WD, path] pair"); } *pathsv = newSVsv (path); @@ -904,8 +896,13 @@ # define const_niv(name, value) { # name, (IV) value }, # define const_iv(name) { # name, (IV) name }, # define const_eio(name) { # name, (IV) EIO_ ## name }, - const_iv (EXDEV) + + /* you have to re-run ./gendef0 after adding/Removing any constants here */ + const_iv (ENOSYS) + const_iv (EXDEV) + const_iv (EBADR) + const_iv (O_RDONLY) const_iv (O_WRONLY) const_iv (O_RDWR) @@ -983,6 +980,34 @@ const_iv (MAP_POPULATE) const_iv (MAP_NONBLOCK) + const_iv (FIEMAP_FLAG_SYNC) + const_iv (FIEMAP_FLAG_XATTR) + const_iv (FIEMAP_FLAGS_COMPAT) + const_iv (FIEMAP_EXTENT_LAST) + const_iv (FIEMAP_EXTENT_UNKNOWN) + const_iv (FIEMAP_EXTENT_DELALLOC) + const_iv (FIEMAP_EXTENT_ENCODED) + const_iv (FIEMAP_EXTENT_DATA_ENCRYPTED) + const_iv (FIEMAP_EXTENT_NOT_ALIGNED) + const_iv (FIEMAP_EXTENT_DATA_INLINE) + const_iv (FIEMAP_EXTENT_DATA_TAIL) + const_iv (FIEMAP_EXTENT_UNWRITTEN) + const_iv (FIEMAP_EXTENT_MERGED) + const_iv (FIEMAP_EXTENT_SHARED) + + const_iv (SPLICE_F_MOVE) + const_iv (SPLICE_F_NONBLOCK) + const_iv (SPLICE_F_MORE) + const_iv (SPLICE_F_GIFT) + + const_iv (SEEK_DATA) + const_iv (SEEK_HOLE) + + /* libeio constants */ + const_eio (SEEK_SET) + const_eio (SEEK_CUR) + const_eio (SEEK_END) + const_eio (MCL_FUTURE) const_eio (MCL_CURRENT) @@ -997,6 +1022,7 @@ const_eio (SYNC_FILE_RANGE_WAIT_AFTER) const_eio (FALLOC_FL_KEEP_SIZE) + const_eio (FALLOC_FL_PUNCH_HOLE) const_eio (READDIR_DENTS) const_eio (READDIR_DIRS_FIRST) @@ -1107,21 +1133,21 @@ aio_syncfs = EIO_SYNCFS PPCODE: { - int fd = s_fileno_croak (fh, 0); + int fd = s_fileno_croak (fh, 0); dREQ; req->type = ix; req->sv1 = newSVsv (fh); req->int1 = fd; - REQ_SEND (req); + REQ_SEND; } void aio_sync_file_range (SV *fh, off_t offset, size_t nbytes, UV flags, SV *callback=&PL_sv_undef) PPCODE: { - int fd = s_fileno_croak (fh, 0); + int fd = s_fileno_croak (fh, 0); dREQ; req->type = EIO_SYNC_FILE_RANGE; @@ -1131,14 +1157,14 @@ req->size = nbytes; req->int2 = flags; - REQ_SEND (req); + REQ_SEND; } void -aio_fallocate (SV *fh, int mode, off_t offset, size_t len, SV *callback=&PL_sv_undef) +aio_allocate (SV *fh, int mode, off_t offset, size_t len, SV *callback=&PL_sv_undef) PPCODE: { - int fd = s_fileno_croak (fh, 0); + int fd = s_fileno_croak (fh, 0); dREQ; req->type = EIO_FALLOCATE; @@ -1148,7 +1174,7 @@ req->offs = offset; req->size = len; - REQ_SEND (req); + REQ_SEND; } void @@ -1156,7 +1182,7 @@ PPCODE: { static int close_fd = -1; /* dummy fd to close fds via dup2 */ - int fd = s_fileno_croak (fh, 0); + int fd = s_fileno_croak (fh, 0); dREQ; if (expect_false (close_fd < 0)) @@ -1182,7 +1208,23 @@ req->sv2 = newSVsv (fh); req->int2 = fd; - REQ_SEND (req); + REQ_SEND; +} + +void +aio_seek (SV *fh, SV *offset, int whence, SV *callback=&PL_sv_undef) + PPCODE: +{ + int fd = s_fileno_croak (fh, 0); + dREQ; + + req->type = EIO_SEEK; + req->sv1 = newSVsv (fh); + req->int1 = fd; + req->offs = SvVAL64 (offset); + req->int2 = whence; + + REQ_SEND; } void @@ -1213,7 +1255,10 @@ { /* read: check type and grow scalar as necessary */ SvUPGRADE (data, SVt_PV); - svptr = SvGROW (data, len + dataoffset + 1); + if (SvLEN (data) >= SvCUR (data)) + svptr = SvGROW (data, len + dataoffset + 1); + else if (SvCUR (data) < len + dataoffset) + croak ("length + dataoffset outside of scalar, and cannot grow"); } { @@ -1257,8 +1302,8 @@ aio_sendfile (SV *out_fh, SV *in_fh, off_t in_offset, size_t length, SV *callback=&PL_sv_undef) PPCODE: { - int ifd = s_fileno_croak (in_fh , 0); - int ofd = s_fileno_croak (out_fh, 1); + int ifd = s_fileno_croak (in_fh , 0); + int ofd = s_fileno_croak (out_fh, 1); dREQ; req->type = EIO_SENDFILE; @@ -1276,7 +1321,7 @@ aio_readahead (SV *fh, off_t offset, size_t length, SV *callback=&PL_sv_undef) PPCODE: { - int fd = s_fileno_croak (fh, 0); + int fd = s_fileno_croak (fh, 0); dREQ; req->type = EIO_READAHEAD; @@ -1298,8 +1343,8 @@ { dREQ; - req->sv1 = newSVsv (fh_or_path); req_set_fh_or_path (req, ix, ix == EIO_STATVFS ? EIO_FSTATVFS : EIO_FSTAT, fh_or_path); + REQ_SEND; } @@ -1423,8 +1468,8 @@ aio_rename = EIO_RENAME PPCODE: { - dREQ; eio_wd wd2 = 0; + dREQ; req->type = ix; req_set_path1 (req, oldpath); @@ -1523,6 +1568,29 @@ } void +aio_fiemap (SV *fh, off_t start, SV *length, U32 flags, SV *count, SV *callback=&PL_sv_undef) + PPCODE: +{ + int fd = s_fileno_croak (fh, 0); + dREQ; + + req->type = EIO_CUSTOM; + req->sv1 = newSVsv (fh); + req->int1 = fd; + + req->feed = fiemap; +#if HAVE_FIEMAP + /* keep our fingers crossed that the next two types are 64 bit */ + req->offs = start; + req->size = SvOK (length) ? SvVAL64 (length) : ~0ULL; + req->int2 = flags; + req->int3 = SvOK (count) ? SvIV (count) : -1; +#endif + + REQ_SEND; +} + +void aio_busy (double delay, SV *callback=&PL_sv_undef) PPCODE: { @@ -1661,7 +1729,7 @@ RETVAL void -mmap (SV *scalar, size_t length, int prot, int flags, SV *fh, off_t offset = 0) +mmap (SV *scalar, size_t length, int prot, int flags, SV *fh = &PL_sv_undef, off_t offset = 0) PPCODE: sv_unmagic (scalar, MMAP_MAGIC); { @@ -1704,7 +1772,7 @@ CODE: { STRLEN svlen; - void *addr = SvPVbyte (scalar, svlen); + void *addr = SvPVbyte (scalar, svlen); size_t len = SvUV (length); if (offset < 0) @@ -1733,7 +1801,7 @@ CODE: { STRLEN svlen; - void *addr = SvPVbyte (scalar, svlen); + void *addr = SvPVbyte (scalar, svlen); size_t len = SvUV (length); if (offset < 0) @@ -1750,7 +1818,7 @@ #if _POSIX_MEMLOCK_RANGE RETVAL = munlock (addr, len); #else - RETVAL = ((errno = ENOSYS), -1); + RETVAL = EIO_ENOSYS (); #endif } OUTPUT: @@ -1762,12 +1830,40 @@ #if _POSIX_MEMLOCK munlockall (); #else - RETVAL = -1; - errno = ENOSYS; + RETVAL = EIO_ENOSYS (); #endif OUTPUT: RETVAL +int +splice (aio_rfd rfh, SV *off_in, aio_wfd wfh, SV *off_out, size_t length, unsigned int flags) + CODE: +{ +#if HAVE_LINUX_SPLICE + loff_t off_in_, off_out_; + RETVAL = splice ( + rfh, SvOK (off_in ) ? (off_in_ = SvVAL64 (off_in )), &off_in_ : 0, + wfh, SvOK (off_out) ? (off_out_ = SvVAL64 (off_out)), &off_out_ : 0, + length, flags + ); +#else + RETVAL = EIO_ENOSYS (); +#endif +} + OUTPUT: + RETVAL + +int +tee (aio_rfd rfh, aio_wfd wfh, size_t length, unsigned int flags) + CODE: +#if HAVE_LINUX_SPLICE + RETVAL = tee (rfh, wfh, length, flags); +#else + RETVAL = EIO_ENOSYS (); +#endif + OUTPUT: + RETVAL + void _on_next_submit (SV *cb) CODE: SvREFCNT_dec (on_next_submit); @@ -1789,11 +1885,15 @@ { aio_wd wd = SvAIO_WD (self); #if HAVE_AT - SV *callback = &PL_sv_undef; - dREQ; /* clobbers next_pri :/ */ - req->type = EIO_WD_CLOSE; - req->wd = wd; - REQ_SEND; + { + SV *callback = &PL_sv_undef; + dREQ; /* clobbers next_pri :/ */ + next_pri = req->pri; /* restore next_pri */ + req->pri = EIO_PRI_MAX; /* better use max. priority to conserve fds */ + req->type = EIO_WD_CLOSE; + req->wd = wd; + REQ_SEND; + } #else eio_wd_close_sync (wd); #endif