Commit 0f7997e2 authored by gregor herrmann's avatar gregor herrmann

Imported Upstream version 4.20

parent 24bf14c7
...@@ -70,7 +70,6 @@ call C<poll_cb> (or other C<aio_> functions) recursively. ...@@ -70,7 +70,6 @@ call C<poll_cb> (or other C<aio_> functions) recursively.
This is a simple example that uses the EV module and loads This is a simple example that uses the EV module and loads
F</etc/passwd> asynchronously: F</etc/passwd> asynchronously:
use Fcntl;
use EV; use EV;
use IO::AIO; use IO::AIO;
...@@ -170,7 +169,7 @@ use common::sense; ...@@ -170,7 +169,7 @@ use common::sense;
use base 'Exporter'; use base 'Exporter';
BEGIN { BEGIN {
our $VERSION = '4.18'; our $VERSION = 4.2;
our @AIO_REQ = qw(aio_sendfile aio_seek aio_read aio_write aio_open aio_close our @AIO_REQ = qw(aio_sendfile aio_seek aio_read aio_write aio_open aio_close
aio_stat aio_lstat aio_unlink aio_rmdir aio_readdir aio_readdirx aio_stat aio_lstat aio_unlink aio_rmdir aio_readdir aio_readdirx
...@@ -605,8 +604,8 @@ Example: stat C</wd> and dump out the data if successful. ...@@ -605,8 +604,8 @@ Example: stat C</wd> and dump out the data if successful.
fsid => 1810 fsid => 1810
} }
Here is a (likely partial) list of fsid values used by Linux - it is safe Here is a (likely partial - send me updates!) list of fsid values used by
to hardcode these when the $^O is C<linux>: Linux - it is safe to hardcode these when C<$^O> is C<linux>:
0x0000adf5 adfs 0x0000adf5 adfs
0x0000adff affs 0x0000adff affs
...@@ -785,7 +784,7 @@ callback. ...@@ -785,7 +784,7 @@ callback.
=item aio_realpath $pathname, $callback->($path) =item aio_realpath $pathname, $callback->($path)
Asynchronously make the path absolute and resolve any symlinks in Asynchronously make the path absolute and resolve any symlinks in
C<$path>. The resulting path only consists of directories (Same as C<$path>. The resulting path only consists of directories (same as
L<Cwd::realpath>). L<Cwd::realpath>).
This request can be used to get the absolute path of the current working This request can be used to get the absolute path of the current working
...@@ -797,6 +796,10 @@ directory by passing it a path of F<.> (a single dot). ...@@ -797,6 +796,10 @@ directory by passing it a path of F<.> (a single dot).
Asynchronously rename the object at C<$srcpath> to C<$dstpath>, just as Asynchronously rename the object at C<$srcpath> to C<$dstpath>, just as
rename(2) and call the callback with the result code. rename(2) and call the callback with the result code.
On systems that support the AIO::WD working directory abstraction
natively, the case C<[$wd, "."]> as C<$srcpath> is specialcased - instead
of failing, C<rename> is called on the absolute path of C<$wd>.
=item aio_mkdir $pathname, $mode, $callback->($status) =item aio_mkdir $pathname, $mode, $callback->($status)
...@@ -810,6 +813,10 @@ request is executed, so do not change your umask. ...@@ -810,6 +813,10 @@ request is executed, so do not change your umask.
Asynchronously rmdir (delete) a directory and call the callback with the Asynchronously rmdir (delete) a directory and call the callback with the
result code. result code.
On systems that support the AIO::WD working directory abstraction
natively, the case C<[$wd, "."]> is specialcased - instead of failing,
C<rmdir> is called on the absolute path of C<$wd>.
=item aio_readdir $pathname, $callback->($entries) =item aio_readdir $pathname, $callback->($entries)
...@@ -1183,7 +1190,7 @@ sub aio_scandir($$;$) { ...@@ -1183,7 +1190,7 @@ sub aio_scandir($$;$) {
=item aio_rmtree $pathname, $callback->($status) =item aio_rmtree $pathname, $callback->($status)
Delete a directory tree starting (and including) C<$path>, return the Delete a directory tree starting (and including) C<$path>, return the
status of the final C<rmdir> only. This is a composite request that status of the final C<rmdir> only. This is a composite request that
uses C<aio_scandir> to recurse into and rmdir directories, and unlink uses C<aio_scandir> to recurse into and rmdir directories, and unlink
everything else. everything else.
...@@ -1313,10 +1320,10 @@ This is a rather advanced IO::AIO call, which works best on mmap(2)ed ...@@ -1313,10 +1320,10 @@ This is a rather advanced IO::AIO call, which works best on mmap(2)ed
scalars. scalars.
It touches (reads or writes) all memory pages in the specified It touches (reads or writes) all memory pages in the specified
range inside the scalar. All caveats and parameters are the same range inside the scalar. All caveats and parameters are the same
as for C<aio_msync>, above, except for flags, which must be either as for C<aio_msync>, above, except for flags, which must be either
C<0> (which reads all pages and ensures they are instantiated) or C<0> (which reads all pages and ensures they are instantiated) or
C<IO::AIO::MT_MODIFY>, which modifies the memory page s(by reading and C<IO::AIO::MT_MODIFY>, which modifies the memory pages (by reading and
writing an octet from it, which dirties the page). writing an octet from it, which dirties the page).
=item aio_mlock $scalar, $offset = 0, $length = undef, $callback->($status) =item aio_mlock $scalar, $offset = 0, $length = undef, $callback->($status)
...@@ -1527,7 +1534,7 @@ pathname will use the directory fd on newer systems, and the string on ...@@ -1527,7 +1534,7 @@ pathname will use the directory fd on newer systems, and the string on
older systems. Some functions (such as realpath) will always rely on the older systems. Some functions (such as realpath) will always rely on the
string form of the pathname. string form of the pathname.
So this fucntionality is mainly useful to get some protection against So this functionality is mainly useful to get some protection against
C<chdir>, to easily get an absolute path out of a relative path for future C<chdir>, to easily get an absolute path out of a relative path for future
reference, and to speed up doing many operations in the same directory reference, and to speed up doing many operations in the same directory
(e.g. when stat'ing all files in a directory). (e.g. when stat'ing all files in a directory).
...@@ -1550,23 +1557,29 @@ request with C<ENOENT>, there is often no need for error checking in the ...@@ -1550,23 +1557,29 @@ request with C<ENOENT>, there is often no need for error checking in the
C<aio_wd> callback, as future requests using the value will fail in the C<aio_wd> callback, as future requests using the value will fail in the
expected way. expected way.
If this call isn't available because your OS lacks it or it couldn't be
detected, it will be emulated by calling C<fsync> instead.
=item IO::AIO::CWD =item IO::AIO::CWD
This is a compiletime constant (object) that represents the process This is a compiletime constant (object) that represents the process
current working directory. current working directory.
Specifying this object as working directory object for a pathname is as Specifying this object as working directory object for a pathname is as if
if the pathname would be specified directly, without a directory object, the pathname would be specified directly, without a directory object. For
e.g., these calls are functionally identical: example, these calls are functionally identical:
aio_stat "somefile", sub { ... }; aio_stat "somefile", sub { ... };
aio_stat [IO::AIO::CWD, "somefile"], sub { ... }; aio_stat [IO::AIO::CWD, "somefile"], sub { ... };
=back =back
To recover the path associated with an IO::AIO::WD object, you can use
C<aio_realpath>:
aio_realpath $wd, sub {
warn "path is $_[0]\n";
};
Currently, C<aio_statvfs> always, and C<aio_rename> and C<aio_rmdir>
sometimes, fall back to using an absolue path.
=head2 IO::AIO::REQ CLASS =head2 IO::AIO::REQ CLASS
...@@ -1754,16 +1767,19 @@ See C<poll_cb> for an example. ...@@ -1754,16 +1767,19 @@ See C<poll_cb> for an example.
=item IO::AIO::poll_cb =item IO::AIO::poll_cb
Process some outstanding events on the result pipe. You have to call Process some requests that have reached the result phase (i.e. they have
this regularly. Returns C<0> if all events could be processed (or there been executed but the results are not yet reported). You have to call
were no events to process), or C<-1> if it returned earlier for whatever this "regularly" to finish outstanding requests.
reason. Returns immediately when no events are outstanding. The amount of
events processed depends on the settings of C<IO::AIO::max_poll_req> and Returns C<0> if all events could be processed (or there were no
C<IO::AIO::max_poll_time>. events to process), or C<-1> if it returned earlier for whatever
reason. Returns immediately when no events are outstanding. The amount
of events processed depends on the settings of C<IO::AIO::max_poll_req>,
C<IO::AIO::max_poll_time> and C<IO::AIO::max_outstanding>.
If not all requests were processed for whatever reason, the filehandle If not all requests were processed for whatever reason, the poll file
will still be ready when C<poll_cb> returns, so normally you don't have to descriptor will still be ready when C<poll_cb> returns, so normally you
do anything special to have it called later. don't have to do anything special to have it called later.
Apart from calling C<IO::AIO::poll_cb> when the event filehandle becomes Apart from calling C<IO::AIO::poll_cb> when the event filehandle becomes
ready, it can be beneficial to call this function from loops which submit ready, it can be beneficial to call this function from loops which submit
...@@ -1782,10 +1798,11 @@ SYNOPSIS section, at the top of this document): ...@@ -1782,10 +1798,11 @@ SYNOPSIS section, at the top of this document):
=item IO::AIO::poll_wait =item IO::AIO::poll_wait
If there are any outstanding requests and none of them in the result Wait until either at least one request is in the result phase or no
phase, wait till the result filehandle becomes ready for reading (simply requests are outstanding anymore.
does a C<select> on the filehandle. This is useful if you want to
synchronously wait for some requests to finish). This is useful if you want to synchronously wait for some requests to
become ready, without actually handling them.
See C<nreqs> for an example. See C<nreqs> for an example.
...@@ -2098,6 +2115,13 @@ See the C<splice(2)> manpage for details. ...@@ -2098,6 +2115,13 @@ See the C<splice(2)> manpage for details.
Calls the GNU/Linux C<tee(2)> syscall, see it's manpage and the Calls the GNU/Linux C<tee(2)> syscall, see it's manpage and the
description for C<IO::AIO::splice> above for details. description for C<IO::AIO::splice> above for details.
=item $actual_size = IO::AIO::pipesize $r_fh[, $new_size]
Attempts to query or change the pipe buffer size. Obviously works only
on pipes, and currently works only on GNU/Linux systems, and fails with
C<-1>/C<ENOSYS> everywhere else. If anybody knows how to influence pipe buffer
size on other systems, drop me a note.
=back =back
=cut =cut
......
...@@ -155,7 +155,7 @@ static void req_destroy (eio_req *grp); ...@@ -155,7 +155,7 @@ static void req_destroy (eio_req *grp);
# define minor(dev) ((dev) & 0xff) # define minor(dev) ((dev) & 0xff)
#endif #endif
#ifndef PAGESIZE #if PAGESIZE <= 0
# define PAGESIZE sysconf (_SC_PAGESIZE) # define PAGESIZE sysconf (_SC_PAGESIZE)
#endif #endif
...@@ -200,7 +200,7 @@ fiemap (eio_req *req) ...@@ -200,7 +200,7 @@ fiemap (eio_req *req)
goto done; goto done;
/* else we have to loop - /* else we have to loop -
* it would be tempting (atcually I tried that first) to just query the * it would be tempting (actually I tried that first) to just query the
* number of extents needed, but linux often feels like not returning all * number of extents needed, but linux often feels like not returning all
* extents, without telling us it left any out. this complicates * extents, without telling us it left any out. this complicates
* this quite a bit. * this quite a bit.
...@@ -223,6 +223,9 @@ fiemap (eio_req *req) ...@@ -223,6 +223,9 @@ fiemap (eio_req *req)
if (ioctl (req->int1, FS_IOC_FIEMAP, incmap) < 0) if (ioctl (req->int1, FS_IOC_FIEMAP, incmap) < 0)
return; return;
if (!incmap->fm_mapped_extents)
goto done;
count = fiemap->fm_mapped_extents + incmap->fm_mapped_extents; count = fiemap->fm_mapped_extents + incmap->fm_mapped_extents;
fiemap = realloc (fiemap, sizeof (*fiemap) + sizeof (struct fiemap_extent) * count); fiemap = realloc (fiemap, sizeof (*fiemap) + sizeof (struct fiemap_extent) * count);
errno = ENOMEM; errno = ENOMEM;
...@@ -1615,7 +1618,10 @@ aio_group (SV *callback=&PL_sv_undef) ...@@ -1615,7 +1618,10 @@ aio_group (SV *callback=&PL_sv_undef)
req->type = EIO_GROUP; req->type = EIO_GROUP;
PUTBACK;
req_submit (req); req_submit (req);
SPAGAIN;
XPUSHs (req_sv (req, aio_grp_stash)); XPUSHs (req_sv (req, aio_grp_stash));
} }
...@@ -1869,6 +1875,22 @@ tee (aio_rfd rfh, aio_wfd wfh, size_t length, unsigned int flags) ...@@ -1869,6 +1875,22 @@ tee (aio_rfd rfh, aio_wfd wfh, size_t length, unsigned int flags)
OUTPUT: OUTPUT:
RETVAL RETVAL
int
pipesize (aio_rfd rfh, int new_size = -1)
PROTOTYPE: $;$
CODE:
#if defined(F_SETPIPE_SZ) && defined(F_GETPIPE_SZ)
if (new_size >= 0)
RETVAL = fcntl (rfh, F_SETPIPE_SZ, new_size);
else
RETVAL = fcntl (rfh, F_GETPIPE_SZ);
#else
errno = ENOSYS;
RETVAL = -1;
#endif
OUTPUT:
RETVAL
void _on_next_submit (SV *cb) void _on_next_submit (SV *cb)
CODE: CODE:
SvREFCNT_dec (on_next_submit); SvREFCNT_dec (on_next_submit);
......
Revision history for IO::AIO Revision history for IO::AIO
TODO: scandir - some dirs mostly contain subdirs - invert logic?
TODO: aio_cptree/mvtree TODO: aio_cptree/mvtree
TODO: reduce condvar fairness: schedule hot-cache-threads first? TODO: reduce condvar fairness: schedule hot-cache-threads first?
TODO: vmsplice? (http://kerneltrap.org/node/6505 http://lwn.net/Articles/178199/) TODO: vmsplice? (http://kerneltrap.org/node/6505 http://lwn.net/Articles/178199/)
...@@ -9,6 +10,32 @@ TODO: getxattr etc.? ...@@ -9,6 +10,32 @@ TODO: getxattr etc.?
TODO: F_DUPFD_CLOEXEC TODO: F_DUPFD_CLOEXEC
TODO: emulation for splice? TODO: emulation for splice?
TODO: eio_mmap|mlock|munmap|splice... TODO: eio_mmap|mlock|munmap|splice...
TODO: syncfs/sync windows:
TODO: F_SETPIPE_SZ, F_GETPIPE_SZ
http://stackoverflow.com/questions/65170/how-to-get-name-associated-with-open-handle/5286888#5286888
http://blogs.msdn.com/b/adioltean/archive/2005/04/16/408947.aspx
http://msdn.microsoft.com/en-us/library/aa366789%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/aa366789%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/aa364425%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/aa364963%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/aa364996%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/aa364994%28v=vs.85%29.aspx
TODO: extra socket/tcp constants &c?
4.2 Sat Jan 25 01:13:14 CET 2014
- aio_group could corrupt memory because it didn't restore
the stack after req_submit.
- be more careful on (e.g. permission) errors in bin/treescan.
- work around changes in ExtUtils::MakeMaker.
- (libeio) implement aio_realpath for win32.
- (xthread) work around compile time bugs in ptw32.
- added IO::AIO::pipesize.
- (libecb) insignificant update.
4.19 Sun Jan 6 12:47:26 CET 2013
- avoid endless loop in fiemap with some XFS files.
- in aio_rename and aio_rmdir, specialcase the case of [$wd, "."]
and call rename/rmdir instead of renameat/unlinkat.
4.18 Thu Oct 11 07:01:26 CEST 2012 4.18 Thu Oct 11 07:01:26 CEST 2012
- fix unintended xthread_create by intentionalising it :) - fix unintended xthread_create by intentionalising it :)
......
...@@ -23,6 +23,7 @@ libeio/xthread.h ...@@ -23,6 +23,7 @@ libeio/xthread.h
libeio/ecb.h libeio/ecb.h
libeio/eio.h libeio/eio.h
libeio/eio.c libeio/eio.c
libeio/etp.c
libeio/libeio.m4 libeio/libeio.m4
libeio/config.h.in libeio/config.h.in
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"unknown" "unknown"
], ],
"dynamic_config" : 1, "dynamic_config" : 1,
"generated_by" : "ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.112150", "generated_by" : "ExtUtils::MakeMaker version 6.86, CPAN::Meta::Converter version 2.133380",
"license" : [ "license" : [
"unknown" "unknown"
], ],
...@@ -22,20 +22,20 @@ ...@@ -22,20 +22,20 @@
"prereqs" : { "prereqs" : {
"build" : { "build" : {
"requires" : { "requires" : {
"ExtUtils::MakeMaker" : 0 "ExtUtils::MakeMaker" : "0"
} }
}, },
"configure" : { "configure" : {
"requires" : { "requires" : {
"ExtUtils::MakeMaker" : 0 "ExtUtils::MakeMaker" : "0"
} }
}, },
"runtime" : { "runtime" : {
"requires" : { "requires" : {
"common::sense" : 0 "common::sense" : "0"
} }
} }
}, },
"release_status" : "stable", "release_status" : "stable",
"version" : "4.18" "version" : "4.2"
} }
...@@ -7,7 +7,7 @@ build_requires: ...@@ -7,7 +7,7 @@ build_requires:
configure_requires: configure_requires:
ExtUtils::MakeMaker: 0 ExtUtils::MakeMaker: 0
dynamic_config: 1 dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.112150' generated_by: 'ExtUtils::MakeMaker version 6.86, CPAN::Meta::Converter version 2.133380'
license: unknown license: unknown
meta-spec: meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html url: http://module-build.sourceforge.net/META-spec-v1.4.html
...@@ -19,4 +19,4 @@ no_index: ...@@ -19,4 +19,4 @@ no_index:
- inc - inc
requires: requires:
common::sense: 0 common::sense: 0
version: 4.18 version: 4.2
...@@ -16,15 +16,20 @@ if ($^O eq "MSWin32") { ...@@ -16,15 +16,20 @@ if ($^O eq "MSWin32") {
*** also, the windows SDK is expected to be installed in /sdk *** also, the windows SDK is expected to be installed in /sdk
*** and visual C is expected to be installed in /vc98 *** and visual C is expected to be installed in /vc98
*** ***
*** Akternatively, set the INC and LIBS environment variables *** Alternatively, set the INC and LIBS environment variables
*** accordingly before running Makeifle.PL, or you can *** accordingly before running Makefile.PL, or you can
*** pass INC and LIBS arguments to Makefile.PL itself. *** pass INC and LIBS arguments to Makefile.PL itself.
*** ***
EOF EOF
$INC = "$ENV{INC} -I/sdk/include -I/vc98/include -I/gtk/include"; if ($Config{cc} =~ /(?:^|\\|\/)gcc(?:|.*\.exe)$/) {
$LIBS = ["$ENV{LIBS} -L/gtk/lib -lpthreadVC2"]; $INC = "$ENV{INC} -I/gtk/include";
$LIBS = ["$ENV{LIBS} -L/gtk/lib -lpthreadGC2"];
} else {
$INC = "$ENV{INC} -I/sdk/include -I/vc98/include -I/gtk/include";
$LIBS = ["$ENV{LIBS} -L/gtk/lib -lpthreadVC2"];
}
open my $fh, ">libeio/config.h" open my $fh, ">libeio/config.h"
or die "libeio/config.h: $!"; or die "libeio/config.h: $!";
...@@ -95,7 +100,7 @@ my $mm = MM->new({ ...@@ -95,7 +100,7 @@ my $mm = MM->new({
SUFFIX => '.gz', SUFFIX => '.gz',
}, },
depend => { depend => {
"AIO.c" => "schmorp.h libeio/eio.h libeio/xthread.h libeio/eio.c libeio/config.h", "AIO.c" => "schmorp.h libeio/eio.h libeio/xthread.h libeio/etp.c libeio/eio.c libeio/config.h",
}, },
NAME => "IO::AIO", NAME => "IO::AIO",
VERSION_FROM => "AIO.pm", VERSION_FROM => "AIO.pm",
...@@ -103,7 +108,7 @@ my $mm = MM->new({ ...@@ -103,7 +108,7 @@ my $mm = MM->new({
LIBS => $LIBS, LIBS => $LIBS,
EXE_FILES => ["bin/treescan"], EXE_FILES => ["bin/treescan"],
PM => { PM => {
'AIO.pm' => '$(INST_LIBDIR)/AIO.pm', 'AIO.pm' => '$(INST_LIB)/IO/AIO.pm',
}, },
PREREQ_PM => { PREREQ_PM => {
"common::sense" => 0, "common::sense" => 0,
......
...@@ -66,7 +66,6 @@ DESCRIPTION ...@@ -66,7 +66,6 @@ DESCRIPTION
This is a simple example that uses the EV module and loads /etc/passwd This is a simple example that uses the EV module and loads /etc/passwd
asynchronously: asynchronously:
use Fcntl;
use EV; use EV;
use IO::AIO; use IO::AIO;
...@@ -532,8 +531,8 @@ FUNCTIONS ...@@ -532,8 +531,8 @@ FUNCTIONS
fsid => 1810 fsid => 1810
} }
Here is a (likely partial) list of fsid values used by Linux - it is Here is a (likely partial - send me updates!) list of fsid values
safe to hardcode these when the $^O is "linux": used by Linux - it is safe to hardcode these when $^O is "linux":
0x0000adf5 adfs 0x0000adf5 adfs
0x0000adff affs 0x0000adff affs
...@@ -694,7 +693,7 @@ FUNCTIONS ...@@ -694,7 +693,7 @@ FUNCTIONS
aio_realpath $pathname, $callback->($path) aio_realpath $pathname, $callback->($path)
Asynchronously make the path absolute and resolve any symlinks in Asynchronously make the path absolute and resolve any symlinks in
$path. The resulting path only consists of directories (Same as $path. The resulting path only consists of directories (same as
Cwd::realpath). Cwd::realpath).
This request can be used to get the absolute path of the current This request can be used to get the absolute path of the current
...@@ -704,6 +703,10 @@ FUNCTIONS ...@@ -704,6 +703,10 @@ FUNCTIONS
Asynchronously rename the object at $srcpath to $dstpath, just as Asynchronously rename the object at $srcpath to $dstpath, just as
rename(2) and call the callback with the result code. rename(2) and call the callback with the result code.
On systems that support the AIO::WD working directory abstraction
natively, the case "[$wd, "."]" as $srcpath is specialcased -
instead of failing, "rename" is called on the absolute path of $wd.
aio_mkdir $pathname, $mode, $callback->($status) aio_mkdir $pathname, $mode, $callback->($status)
Asynchronously mkdir (create) a directory and call the callback with Asynchronously mkdir (create) a directory and call the callback with
the result code. $mode will be modified by the umask at the time the the result code. $mode will be modified by the umask at the time the
...@@ -713,6 +716,10 @@ FUNCTIONS ...@@ -713,6 +716,10 @@ FUNCTIONS
Asynchronously rmdir (delete) a directory and call the callback with Asynchronously rmdir (delete) a directory and call the callback with
the result code. the result code.
On systems that support the AIO::WD working directory abstraction
natively, the case "[$wd, "."]" is specialcased - instead of
failing, "rmdir" is called on the absolute path of $wd.
aio_readdir $pathname, $callback->($entries) aio_readdir $pathname, $callback->($entries)
Unlike the POSIX call of the same name, "aio_readdir" reads an Unlike the POSIX call of the same name, "aio_readdir" reads an
entire directory (i.e. opendir + readdir + closedir). The entries entire directory (i.e. opendir + readdir + closedir). The entries
...@@ -944,7 +951,7 @@ FUNCTIONS ...@@ -944,7 +951,7 @@ FUNCTIONS
inside the scalar. All caveats and parameters are the same as for inside the scalar. All caveats and parameters are the same as for
"aio_msync", above, except for flags, which must be either 0 (which "aio_msync", above, except for flags, which must be either 0 (which
reads all pages and ensures they are instantiated) or reads all pages and ensures they are instantiated) or
"IO::AIO::MT_MODIFY", which modifies the memory page s(by reading "IO::AIO::MT_MODIFY", which modifies the memory pages (by reading
and writing an octet from it, which dirties the page). and writing an octet from it, which dirties the page).
aio_mlock $scalar, $offset = 0, $length = undef, $callback->($status) aio_mlock $scalar, $offset = 0, $length = undef, $callback->($status)
...@@ -1155,7 +1162,7 @@ FUNCTIONS ...@@ -1155,7 +1162,7 @@ FUNCTIONS
older systems. Some functions (such as realpath) will always rely on the older systems. Some functions (such as realpath) will always rely on the
string form of the pathname. string form of the pathname.
So this fucntionality is mainly useful to get some protection against So this functionality is mainly useful to get some protection against
"chdir", to easily get an absolute path out of a relative path for "chdir", to easily get an absolute path out of a relative path for
future reference, and to speed up doing many operations in the same future reference, and to speed up doing many operations in the same
directory (e.g. when stat'ing all files in a directory). directory (e.g. when stat'ing all files in a directory).
...@@ -1175,20 +1182,27 @@ FUNCTIONS ...@@ -1175,20 +1182,27 @@ FUNCTIONS
checking in the "aio_wd" callback, as future requests using the checking in the "aio_wd" callback, as future requests using the
value will fail in the expected way. value will fail in the expected way.
If this call isn't available because your OS lacks it or it couldn't
be detected, it will be emulated by calling "fsync" instead.
IO::AIO::CWD IO::AIO::CWD
This is a compiletime constant (object) that represents the process This is a compiletime constant (object) that represents the process
current working directory. current working directory.
Specifying this object as working directory object for a pathname is Specifying this object as working directory object for a pathname is
as if the pathname would be specified directly, without a directory as if the pathname would be specified directly, without a directory
object, e.g., these calls are functionally identical: object. For example, these calls are functionally identical:
aio_stat "somefile", sub { ... }; aio_stat "somefile", sub { ... };
aio_stat [IO::AIO::CWD, "somefile"], sub { ... }; aio_stat [IO::AIO::CWD, "somefile"], sub { ... };
To recover the path associated with an IO::AIO::WD object, you can use
"aio_realpath":
aio_realpath $wd, sub {
warn "path is $_[0]\n";
};
Currently, "aio_statvfs" always, and "aio_rename" and "aio_rmdir"
sometimes, fall back to using an absolue path.
IO::AIO::REQ CLASS IO::AIO::REQ CLASS
All non-aggregate "aio_*" functions return an object of this class when All non-aggregate "aio_*" functions return an object of this class when
called in non-void context. called in non-void context.
...@@ -1349,16 +1363,20 @@ FUNCTIONS ...@@ -1349,16 +1363,20 @@ FUNCTIONS
See "poll_cb" for an example. See "poll_cb" for an example.
IO::AIO::poll_cb IO::AIO::poll_cb
Process some outstanding events on the result pipe. You have to call Process some requests that have reached the result phase (i.e. they
this regularly. Returns 0 if all events could be processed (or there have been executed but the results are not yet reported). You have
were no events to process), or -1 if it returned earlier for to call this "regularly" to finish outstanding requests.
whatever reason. Returns immediately when no events are outstanding.
The amount of events processed depends on the settings of
"IO::AIO::max_poll_req" and "IO::AIO::max_poll_time".
If not all requests were processed for whatever reason, the Returns 0 if all events could be processed (or there were no events
filehandle will still be ready when "poll_cb" returns, so normally to process), or -1 if it returned earlier for whatever reason.
you don't have to do anything special to have it called later. Returns immediately when no events are outstanding. The amount of
events processed depends on the settings of "IO::AIO::max_poll_req",
"IO::AIO::max_poll_time" and "IO::AIO::max_outstanding".
If not all requests were processed for whatever reason, the poll
file descriptor will still be ready when "poll_cb" returns, so
normally you don't have to do anything special to have it called
later.
Apart from calling "IO::AIO::poll_cb" when the event filehandle Apart from calling "IO::AIO::poll_cb" when the event filehandle
becomes ready, it can be beneficial to call this function from loops becomes ready, it can be beneficial to call this function from loops
...@@ -1376,10 +1394,11 @@ FUNCTIONS ...@@ -1376,10 +1394,11 @@ FUNCTIONS
cb => \&IO::AIO::poll_cb); cb => \&IO::AIO::poll_cb);
IO::AIO::poll_wait IO::AIO::poll_wait
If there are any outstanding requests and none of them in the result Wait until either at least one request is in the result phase or no
phase, wait till the result filehandle becomes ready for reading requests are outstanding anymore.
(simply does a "select" on the filehandle. This is useful if you
want to synchronously wait for some requests to finish). This is useful if you want to synchronously wait for some requests
to become ready, without actually handling them.
See "nreqs" for an example. See "nreqs" for an example.
...@@ -1664,6 +1683,12 @@ FUNCTIONS ...@@ -1664,6 +1683,12 @@ FUNCTIONS
Calls the GNU/Linux tee(2) syscall, see it's manpage and the Calls the GNU/Linux tee(2) syscall, see it's manpage and the
description for "IO::AIO::splice" above for details. description for "IO::AIO::splice" above for details.
$actual_size = IO::AIO::pipesize $r_fh[, $new_size]
Attempts to query or change the pipe buffer size. Obviously works
only on pipes, and currently works only on GNU/Linux systems, and
fails with -1/"ENOSYS" everywhere else. If anybody knows how to
influence pipe buffer size on other systems, drop me a note.
EVENT LOOP INTEGRATION EVENT LOOP INTEGRATION
It is recommended to use AnyEvent::AIO to integrate IO::AIO It is recommended to use AnyEvent::AIO to integrate IO::AIO
automatically into many event loops: automatically into many event loops:
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# inspired by treescan by Jamie Lokier <jamie@imbolc.ucc.ie> # inspired by treescan by Jamie Lokier <jamie@imbolc.ucc.ie>
# about 40% faster than the original version (on my fs and raid :) # about 40% faster than the original version (on my fs and raid :)
use strict; use common::sense;
use Getopt::Long; use Getopt::Long;
use Time::HiRes (); use Time::HiRes ();
use IO::AIO; use IO::AIO;
...@@ -67,7 +67,7 @@ sub scan { ...@@ -67,7 +67,7 @@ sub scan {
++$n_dirs; ++$n_dirs;
aio_scandir $path, 8, sub { aio_scandir $path, 8, sub {
my ($dirs, $files) = @_ my ($dirs, $files) = @_
or warn "$path: $!\n"; or return warn "$path: $!\n";
printfn "", [$path] unless $opt_nodirs; printfn "", [$path] unless $opt_nodirs;
printfn $path, $files unless $opt_nofiles; printfn $path, $files unless $opt_nofiles;
......
/* GENERATED FILE */
/* use ./gendef0 to regenerate this file */
#ifndef ENOSYS #ifndef ENOSYS
#define ENOSYS 0 #define ENOSYS 0
#endif #endif
......
...@@ -6,6 +6,11 @@ open STDIN, "<AIO.xs" ...@@ -6,6 +6,11 @@ open STDIN, "<AIO.xs"
open STDOUT, ">def0.h" open STDOUT, ">def0.h"
or die "def0.h: $!"; or die "def0.h: $!";
print <<EOF;
/* GENERATED FILE */
/* use ./gendef0 to regenerate this file */
EOF
while (<>) { while (<>) {
if (/^\s*const_iv\s*\((\S+)\)\s*$/ || /^\s*const_niv\s*\([^,]+,\s*(\S+)\)\s*$/) { if (/^\s*const_iv\s*\((\S+)\)\s*$/ || /^\s*const_niv\s*\([^,]+,\s*(\S+)\)\s*$/) {
print "#ifndef $1\n", print "#ifndef $1\n",
......