--- IO-AIO/AIO.pm 2011/06/10 06:50:42 1.196 +++ IO-AIO/AIO.pm 2011/07/25 16:50:33 1.207 @@ -170,12 +170,13 @@ use base 'Exporter'; BEGIN { - our $VERSION = '3.9'; + our $VERSION = '4.0'; our @AIO_REQ = qw(aio_sendfile aio_read aio_write aio_open aio_close aio_stat aio_lstat aio_unlink aio_rmdir aio_readdir aio_readdirx - aio_scandir aio_symlink aio_readlink aio_sync aio_fsync - aio_fdatasync aio_sync_file_range aio_pathsync aio_readahead + aio_scandir aio_symlink aio_readlink aio_realpath aio_sync + aio_fsync aio_syncfs aio_fdatasync aio_sync_file_range aio_fallocate + aio_pathsync aio_readahead aio_rename aio_link aio_move aio_copy aio_group aio_nop aio_mknod aio_load aio_rmtree aio_mkdir aio_chown aio_chmod aio_utime aio_truncate @@ -224,6 +225,7 @@ aio_link $srcpath, $dstpath, $callback->($status) aio_symlink $srcpath, $dstpath, $callback->($status) aio_readlink $path, $callback->($link) + aio_realpath $path, $callback->($link) aio_rename $srcpath, $dstpath, $callback->($status) aio_mkdir $pathname, $mode, $callback->($status) aio_rmdir $pathname, $callback->($status) @@ -237,6 +239,7 @@ aio_scandir $path, $maxreq, $callback->($dirs, $nondirs) aio_rmtree $path, $callback->($status) aio_sync $callback->($status) + aio_syncfs $fh, $callback->($status) aio_fsync $fh, $callback->($status) aio_fdatasync $fh, $callback->($status) aio_sync_file_range $fh, $offset, $nbytes, $flags, $callback->($status) @@ -645,6 +648,16 @@ callback. +=item aio_realpath $path, $callback->($path) + +Asynchronously make the path absolute and resolve any symlinks in +C<$path>. The resulting path only consists of directories (Same as +L). + +This request can be used to get the absolute path of the current working +directory by passing it a path of F<.> (a single dot). + + =item aio_rename $srcpath, $dstpath, $callback->($status) Asynchronously rename the object at C<$srcpath> to C<$dstpath>, just as @@ -676,8 +689,8 @@ =item aio_readdirx $pathname, $flags, $callback->($entries, $flags) -Quite similar to C, but the C<$flags> argument allows to tune -behaviour and output format. In case of an error, C<$entries> will be +Quite similar to C, but the C<$flags> argument allows one to +tune behaviour and output format. In case of an error, C<$entries> will be C. The flags are a combination of the following constants, ORed together (the @@ -734,7 +747,7 @@ This flag should not be set when calling C. Instead, it is being set by C, when any of the C<$type>'s found were -C. The absense of this flag therefore indicates that all +C. The absence of this flag therefore indicates that all C<$type>'s are known, which can be used to speed up some algorithms. =back @@ -926,7 +939,7 @@ entry plus an appended C will be C'ed, likely directories first, in order of their inode numbers. If that succeeds, it assumes that the entry is a directory or a symlink to directory (which will be checked -seperately). This is often faster than stat'ing the entry itself because +separately). This is often faster than stat'ing the entry itself because filesystems might detect the type of the entry without reading the inode data (e.g. ext2fs filetype feature), even on systems that cannot return the filetype information on readdir. @@ -1074,6 +1087,13 @@ If this call isn't available because your OS lacks it or it couldn't be detected, it will be emulated by calling C instead. +=item aio_syncfs $fh, $callback->($status) + +Asynchronously call the syncfs syscall to sync the filesystem associated +to the given filehandle and call the callback with the syncfs result +code. If syncfs is not available, calls sync(), but returns C<-1> and sets +errno to C nevertheless. + =item aio_sync_file_range $fh, $offset, $nbytes, $flags, $callback->($status) Sync the data portion of the file specified by C<$offset> and C<$length> @@ -1655,7 +1675,7 @@ Simply calls the C function (see its manpage for details). The following advice constants are -avaiable: C, C, +available: C, C, C, C, C, C. @@ -1666,7 +1686,7 @@ Simply calls the C function (see its manpage for details). The following advice constants are -avaiable: C, C, +available: C, C, C, C, C. On systems that do not implement C, this function returns @@ -1676,7 +1696,7 @@ Simply calls the C function on the preferably AIO::mmap'ed $scalar (see its manpage for details). The following protect -constants are avaiable: C, C, +constants are available: C, C, C, C. On systems that do not implement C, this function returns @@ -1791,19 +1811,36 @@ =head2 FORK BEHAVIOUR -This module should do "the right thing" when the process using it forks: +Usage of pthreads in a program changes the semantics of fork +considerably. Specifically, only async-safe functions can be called after +fork. Perl doesn't know about this, so in general, you cannot call fork +with defined behaviour in perl if pthreads are involved. IO::AIO uses +pthreads, so this applies, but many other extensions and (for inexplicable +reasons) perl itself often is linked against pthreads, so this limitation +applies to quite a lot of perls. + +This module no longer tries to fight your OS, or POSIX. That means IO::AIO +only works in the process that loaded it. Forking is fully supported, but +using IO::AIO in the child is not. + +You might get around by not I IO::AIO before (or after) +forking. You could also try to call the L function in the +child: -Before the fork, IO::AIO enters a quiescent state where no requests -can be added in other threads and no results will be processed. After -the fork the parent simply leaves the quiescent state and continues -request/result processing, while the child frees the request/result queue -(so that the requests started before the fork will only be handled in the -parent). Threads will be started on demand until the limit set in the -parent process has been reached again. - -In short: the parent will, after a short pause, continue as if fork had -not been called, while the child will act as if IO::AIO has not been used -yet. +=over 4 + +=item IO::AIO::reinit + +Abandons all current requests and I/O threads and simply reinitialises all +data structures. This is not an operation supported by any standards, but +happens to work on GNU/Linux and some newer BSD systems. + +The only reasonable use for this function is to call it after forking, if +C was used in the parent. Calling it while IO::AIO is active in +the process will result in undefined behaviour. Calling it at any time +will also result in any undefined (by POSIX) behaviour. + +=back =head2 MEMORY USAGE