Commit 1a2f1abf authored by Nicholas Bamber's avatar Nicholas Bamber

[svn-inject] Installing original source of libio-aio-perl (2.4)

parents
This diff is collapsed.
This diff is collapsed.
This module is licensed under the same terms as perl itself.
Revision history for IO::AIO
TODO: better autoconf.pm that can return LIBS etc.
TODO: aio_cptree/mvtree
TODO: reduce condvar fairness: schedule hot-cache-threads first?
TODO: fix setsig
TODO: splice/tee/vmsplice/sync_file_range? (http://kerneltrap.org/node/6505 http://lwn.net/Articles/178199/)
2.4 Sun Aug 5 18:44:22 CEST 2007
- add aio_truncate, aio_chmod, aio_chown, aio_utime (linux
successfully demonstrated that you can block on futimes...).
- allow undef as fileoffset for aio_read/write and use read/write(2)
internally (useful for sockets or O_APPEND handles).
- allow undef for length in aio_write.
- negative dataoffsets work as expected now in aio_read/aio_write.
- use NV instead of UV for 32 bit perls and file offsets, as NVs
have a larger range then.
- shared code between BDB and IO::AIO.
- aio_busy was completely broken. now fixed.
- readahead emulation now returns something.
- correctly set errno to ENOSYS on unimplemented functions
(should never happen, though).
- large changes to make it partially compile and run on win32,
but win32 lacks too much functionality, and perl overrides way
too many functions with crashing versions.
2.33 Tue Jan 23 23:55:41 CET 2007
- fix install path (Andreas J. Koenig).
2.32 Mon Jan 22 16:56:23 CET 2007
- added aio_rmtree.
- wow, aio_mkdir was missing.
- aio_load did return undef on error, not -1.
- use prefixexp not prefix in autoconf.pm
(suggested by ... rt.cpan.org unreachable).
- avoid installing autoconf.pm.
2.31 Sat Jan 6 03:46:02 CET 2007
- added aio_load.
2.3 Sat Dec 23 05:48:07 CET 2006
- fix off-by-one bug in aio_read, causing memory corruption
or crashes.
2.21 Fri Dec 22 05:03:38 CET 2006
- minor doc updates.
- minor cleanups.
- IO::AIO::poll returns request count.
- undocumented and unfinished async-signal-reporting.
2.2 Tue Oct 31 00:31:00 CET 2006
- minor doc updates.
- added aio_readlink.
- properly zero-terminate aio_read buffer.
- fix aio_read/write with nonzero dataoffset.
- reduced size of aio request structure.
- better diagnostics when pathnames etc. are not byte-encoded;
do not leak request in that case, either.
2.1 Sun Oct 29 02:01:57 CET 2006
- INCOMPATIBLE CHANGE: replace IO::AIO::poll_some by
IO::AIO::max_poll_reqs and IO::AIO::max_poll_time.
- fix a bug in aio_move where it would fail everytime
it would have to copy files manually.
- doc updates.
- start threads only on (very low) demand.
- end superfluous threads automatically after 10s idling.
- add IO::AIO::max_idle to control this.
- some tuning applied to random places.
- add aio_mknod.
2.0 Thu Oct 26 18:27:58 CEST 2006
- minor incompatibility: max_outstanding semantics have changed.
- major rewrite, consider all functionality EXPERIMENTAL.
- aio requests can be cancelled.
- callbacks can be (re-)set later.
- aio requests can choose between 9 priorities.
- add aio_group: aio requests can be grouped
into composite requests.
- generator interface for groups.
- add IO::AIO::poll_some.
- major documentation improvements.
- very minor bugfixes.
- add aio_nop for dummy requests.
- add aio_busy mainly for benchmarking and debugging.
- use "fast" mutexes on linux.
- use dynamic (and larger) buffers instead of
putting them onto the stack.
- optimise x86 and amd64 a bit.
- better error checking when ENOMEM.
- hopefully fix mem and dirp leaks on fork.
- warn about broken perl malloc.
- compiles on cygwin (but pread is broken on cygwin
which is not detected by autoconf, so you have to
edit autoconf/config.h yourself to enable emulation).
1.8 Sat Jun 24 22:20:44 CEST 2006
- add and/or document aio_rename, aio_link, aio_symlink and aio_move.
1.73 Wed Mar 1 22:49:32 CET 2006
- codename "jost"
- AIX/Solaris(?) aren't being helpful again, hardcode a value
for NAME_MAX and drive with your eyes closed (reported by
wcooley@nakedape.cc).
1.72 Thu Feb 2 00:40:44 CET 2006
- another minor bug in aio_scandir, again, the callback was called
twice when the directory can't be stat'ed.
1.71 Mon Dec 26 20:20:03 CET 2005
- grr, another minor bug in aio_scandir, this time resulting
in a runtime error.
1.7 Mon Dec 26 19:29:48 CET 2005
- aio_scandir errornously called callback twice in some cases.
- added AnyEvent example.
1.61 Wed Sep 7 19:40:42 CEST 2005
- no longer include $Config{libs}, as distros include too much
garbage in there that is not installed on typical systems
(for example, debian links perl against -lgdbm and many more
libraries despite perl not needing it, slowing down startup and
wasting memory).
1.6 Tue Aug 30 17:44:44 CEST 2005
- added aio_readdir, aio_scandir.
- added aio_sendfile, including sendfile emulation when sendfile
isn't available. Linux, FreeBSD and HP-UX might work (sendfilev
support is unavailable on my solaris 8 machine, but preliminary
code is there. What's lacking is configury stuff and testing...).
1.5 Sat Aug 20 02:32:19 CEST 2005
- create the aio threads on demand only (good after forking).
- somebody nagged about C89 compatibility, so this release should
be C89 compatible, but no guarantees for future ones.
- abort when the configure script fails.
1.4 Wed Aug 17 08:07:27 CEST 2005
- forgot to recreate the pipe after forking, this could cause
deadlocks.
1.3 Wed Aug 17 07:25:54 CEST 2005
- properly propagate exceptions from callbacks, instead of silently
eating them.
- use a different fork algorithm that avoids recursive callback
invocations and reduces fork latency in busy processes.
- fix a bug where the buffer scalar in aio_read got assigned the wrong
length after reading.
- fix a bug where the child would process some outstanding requests
from the parent.
- make a copy of the callback scalar, to avoid some very uncommon
(but valid) usages where the callback scalar changes.
- the callback was never freed in aio_read/aio_write.
- aio_read/aio_write will now set the readonly flag on the data
scalar for better error reporting.
1.2 Wed Aug 17 01:22:58 CEST 2005
- verified on cygwin, linux/amd64+ia32+alpha, solaris.
- use SvPVbyte for filenames now. You *need* to encode your strings to
the external filename encoding first.
- fix the bug where filehandles could leak (again).
- clarify freebsd situation: make it work and tell me how, or go away
with your underdocumented, broken and outdated OS.
- fork'ing should now be officially supported (where linux and
posix contradict each other, I followed posix).
- only call read() once per poll, not twice (speedup).
- new functions: aio_rmdir, aio_symlink.
- force callback arguments to be undef or a reference, for better
error catching.
1.1 Sun Aug 7 05:27:23 CEST 2005
- added configure script to detect availability of some calls.
(imperfect, as we cannot detect things like -lrt due to missing
feedback yet).
- emulate fdatasync via fsync, pread/pwrite via unsafe read/write
and readahead via manual reading on platforms lacking those.
- ported t/03_errors.t+framework by Brad Fitzpatrick
from Linux::AIO.
- removed XOPEN_SOURCE because stupid solaris 9 doesn't
compile with it enabled. Probably breaks others. Oh well.
- try to be more careful with errno on non-threaded perls.
- cygwins perl insisted on a matching open mode when morphing
the fd to an fh.
- convert sv's to "byte" encoding in aio_read/aio_write. Might
do that for pathnames, too, in the future, so make sure you
properly encode your pathnames.
1.0 Fri Jul 22 10:43:30 CEST 2005
- aio_open did not reliably deliver (open) filehandles.
- all aio_*-functions keep a reference to the filehandle so
it doesn't go away while the aio requests is working on it.
- disable warnings in AIO.pm.
0.9 Wed Jul 20 23:55:04 CEST 2005
- allow recursive calls to poll_cb, use less locking calls, too.
- fix the Gtk2-example in the SYNOPSIS.
- use pread/pwrite not pread64/pwrite64. this was simply a leftover
from Linux::AIO.
(found by compiling on cygwin. Unfortunately, cygwin declares but
does not implement pread/pwrite).
- only include <sys/syscall.h> on linux.
0.5 Tue Jul 12 13:03:09 CEST 2005
- removed #include <endian.h>, it's not portable, and we don't
need it anyway.
- link against -lrt, as it might contain goodies such as fdatasync,
and often aio_read, which we do not use yet, but it shouldn't hurt.
0.4 Mon Jul 11 05:28:25 CEST 2005
- added IO::AIO::flush, IO::AIO::poll.
- make callback argument optional for all calls.
0.3 Mon Jul 11 01:42:37 CEST 2005
- restructured manpage.
- added SYNOPSIS with examples for Event, Glib, Tk.
- remove explicit context support so I don't have to maintain
it for threaded perls (i.e. it should work now :).
0.2 Sun Jul 10 22:57:12 CEST 2005
- return immediately from poll_wait if nreqs==0.
- get rid of the request pipe and use faster thread-thread
communications for most requests and responses.
0.1
- cloned from Linux::AIO, which is very similar.
README
MANIFEST
COPYING
Changes
Makefile.PL
AIO.pm
AIO.xs
xthread.h
t/00_load.t
t/01_stat.t
t/02_read.t
t/03_errors.t
t/04_fork.t
t/05_readdir.t
t/06_group.t
t/07_feeder.t
t/aio_test_common.pm
typemap
genac
autoconf.pm
autoconf/configure.ac
autoconf/configure
autoconf/config.h.in
META.yml Module meta-data (added by MakeMaker)
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: IO-AIO
version: 2.4
version_from: AIO.pm
installdirs: site
requires:
distribution_type: module
generated_by: ExtUtils::MakeMaker version 6.30
use ExtUtils::MakeMaker;
use Config;
require "autoconf.pm";
if ($^O =~ /win32/i or $^O =~ /mswin/) {
# configuration on windows is hardcoded - as always
warn "your platform is not standards-compliant, you have to port this module first\n";
warn "using some hardcoded config that will not work on your system\n";
$INC = "-I/Perl/lib/CORE -I/sdk/include -I/vc98/include -I/gtk/include -I/gtk/include/pango-1.0 -I/gtk/include/glib-2.0 -I/gtk/lib/glib-2.0/include/ -I/gtk/include/freetype2";
$LIBS = ["-L/gtk/lib -lpthreadVC2"];
} else {
$INC = "";
$LIBS = ['-lpthread -lrt', '-lpthread', '-lpthreads', '-lpthreadVC2', ''];
if ($^O =~ /freebsd/i) {
print <<EOF;
This package seems to deadlock or otherwise misbehave under FreeBSD. As
documentation on FreeBSD threading is sorely lacking and confusing, I'll
just call FreeBSD broken with regards to threading.
If you find out whats wrong, please tell me.
Some people had luck with using OPTIMIZE=-O instead of -O2, so you might
want to try that.
EOF
}
autoconf::run_script()
and die "\nconfigure failed, check it's output above and autoconf/config.log\n\n";
}
if ($^O =~ /linux/ && $Config{usemymalloc} eq "y") {
print <<EOF;
***
*** WARNING:
***
*** Your perl uses it's own memory allocator (-Dusemymalloc=y),
*** which is known not to be threadsafe on GNU/Linux and probably
*** other platforms (even when not used concurrently, it trashes
*** the data structures of the system malloc running concurrently),
*** for perls up to 5.8.8 and possibly later versions.
***
*** If you are unsure wether your perl has been fixed, your system
*** is safe for other reasons, or you experience spurious segfaults,
*** please compile your perl with -Dusemymalloc=n.
***
EOF
}
my $mm = MM->new({
dist => {
PREOP => 'pod2text AIO.pm | tee README >$(DISTVNAME)/README; chmod -R u=rwX,go=rX . ;',
COMPRESS => 'gzip -9v',
SUFFIX => '.gz',
},
NAME => "IO::AIO",
VERSION_FROM => "AIO.pm",
INC => $INC,
LIBS => $LIBS,
PM => {
'AIO.pm' => '$(INST_LIBDIR)/AIO.pm',
},
clean => { FILES => "autoconf/config.h autoconf/config.log autoconf/config.status" },
});
$mm->flush;
This diff is collapsed.
package autoconf;
# I plan to improve this and make it a standalone ExtUtils::Autoconf module,
# but right now it just runs an external configure script.
use Config;
sub run_script(;$$) {
my ($wd, $file) = @_;
$wd ||= "autoconf";
$script ||= "./configure";
local %ENV = %ENV;
while (my ($k, $v) = each %Config) {
$ENV{$k} = $v;
}
$ENV{MAKE} = $Config{make};
$ENV{SHELL} = $Config{sh};
$ENV{CC} = $Config{cc};
$ENV{CPPFLAGS} = $Config{cppflags};
$ENV{CFLAGS} = $Config{ccflags};
$ENV{LDFLAGS} = $Config{ldflags};
$ENV{LIBS} = "";
$ENV{LINKER} = $Config{ld}; # nonstandard
my $status = system $ENV{SHELL}, -c => "cd \Q$wd\E && \Q$script\E --prefix \Q$Config{prefixexp}\E";
$status
}
1
/* config.h.in. Generated from configure.ac by autoheader. */
/* fdatasync(2) is available */
#undef HAVE_FDATASYNC
/* futimes(2) is available */
#undef HAVE_FUTIMES
/* pread(2) and pwrite(2) are available */
#undef HAVE_PREADWRITE
/* readahead(2) is available (linux) */
#undef HAVE_READAHEAD
/* readdir_r is available */
#undef HAVE_READDIR_R
/* sendfile(2) is available and supported */
#undef HAVE_SENDFILE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
This diff is collapsed.
AC_PREREQ(2.59)
AC_INIT
AC_CONFIG_HEADERS([config.h])
AC_PROG_CC
AC_CACHE_CHECK(for futimes, ac_cv_futimes, [AC_LINK_IFELSE([[
#include <sys/types.h>
#include <sys/time.h>
#include <utime.h>
struct timeval tv[2];
int res;
int fd;
int main(void)
{
res = futimes (fd, tv);
return 0;
}
]],ac_cv_futimes=yes,ac_cv_futimes=no)])
test $ac_cv_futimes = yes && AC_DEFINE(HAVE_FUTIMES, 1, futimes(2) is available)
AC_CACHE_CHECK(for readahead, ac_cv_readahead, [AC_LINK_IFELSE([
#include <fcntl.h>
int main(void)
{
int fd = 0;
off64_t offset = 1;
size_t count = 2;
ssize_t res;
res = readahead (fd, offset, count);
return 0;
}
],ac_cv_readahead=yes,ac_cv_readahead=no)])
test $ac_cv_readahead = yes && AC_DEFINE(HAVE_READAHEAD, 1, readahead(2) is available (linux))
AC_CACHE_CHECK(for fdatasync, ac_cv_fdatasync, [AC_LINK_IFELSE([
#include <unistd.h>
int main(void)
{
int fd = 0;
fdatasync (fd);
return 0;
}
],ac_cv_fdatasync=yes,ac_cv_fdatasync=no)])
test $ac_cv_fdatasync = yes && AC_DEFINE(HAVE_FDATASYNC, 1, fdatasync(2) is available)
AC_CACHE_CHECK(for pread and pwrite, ac_cv_preadwrite, [AC_LINK_IFELSE([
#include <unistd.h>
int main(void)
{
int fd = 0;
size_t count = 1;
char buf;
off_t offset = 1;
ssize_t res;
res = pread (fd, &buf, count, offset);
res = pwrite (fd, &buf, count, offset);
return 0;
}
],ac_cv_preadwrite=yes,ac_cv_preadwrite=no)])
test $ac_cv_preadwrite = yes && AC_DEFINE(HAVE_PREADWRITE, 1, pread(2) and pwrite(2) are available)
AC_CACHE_CHECK(for readdir_r, ac_cv_readdir_r, [AC_LINK_IFELSE([
#include <dirent.h>
int main(void)
{
DIR *dir = 0;
struct dirent ent, *eres;
int res = readdir_r (dir, &ent, &eres);
return 0;
}
],ac_cv_readdir_r=yes,ac_cv_readdir_r=no)])
test $ac_cv_readdir_r = yes && AC_DEFINE(HAVE_READDIR_R, 1, readdir_r is available)
AC_CACHE_CHECK(for sendfile, ac_cv_sendfile, [AC_LINK_IFELSE([
# include <sys/types.h>
#if __linux
# include <sys/sendfile.h>
#elif __freebsd
# include <sys/socket.h>
# include <sys/uio.h>
#elif __hpux
# include <sys/socket.h>
#else
# error unsupported architecture
#endif
int main(void)
{
int fd = 0;
off_t offset = 1;
size_t count = 2;
ssize_t res;
#if __linux
res = sendfile (fd, fd, offset, count);
#elif __freebsd
res = sendfile (fd, fd, offset, count, 0, &offset, 0);
#elif __hpux
res = sendfile (fd, fd, offset, count, 0, 0);
#endif
return 0;
}
],ac_cv_sendfile=yes,ac_cv_sendfile=no)])
test $ac_cv_sendfile = yes && AC_DEFINE(HAVE_SENDFILE, 1, sendfile(2) is available and supported)
AC_OUTPUT
cd autoconf || exit 69
autoconf
autoheader
BEGIN { $| = 1; print "1..3\n"; }
END {print "not ok 1\n" unless $loaded;}
use IO::AIO;
$loaded = 1;
print "ok 1\n";
IO::AIO::min_parallel(10);
print "ok 2\n";
IO::AIO::max_parallel(0);
print "ok 3\n";
$| = 1;
if (-f "/etc/passwd" and -d "/etc") {
print "1..10\n";
} else {
print "1..0 # Skipped: unexpected /etc and/or /etc/passwd\n";
exit;
}
# relies on /etc/passwd to exist...
use Fcntl;
use IO::AIO;
IO::AIO::min_parallel 2;
sub pcb {
while (IO::AIO::nreqs) {
my $rfd = ""; vec ($rfd, IO::AIO::poll_fileno, 1) = 1; select $rfd, undef, undef, undef;
IO::AIO::poll_cb;
}
}
aio_open "/etc/passwd", O_RDONLY, 0, sub {
print $_[0] ? "ok" : "not ok", " 1\n";
$pwd = $_[0];
};
pcb;
aio_stat "/etc", sub {
print -d _ ? "ok" : "not ok", " 2\n";
};
pcb;
aio_stat "/etc/passwd", sub {
@pwd = stat _;
print -f _ ? "ok" : "not ok", " 3\n";
print eval { lstat _; 1 } ? "not ok" : "ok", " 4\n";
};
pcb;
aio_lstat "/etc/passwd", sub {
lstat _;
print -f _ ? "ok" : "not ok", " 5\n";
print eval { stat _; 1 } ? "ok" : "not ok", " 6\n";
};
pcb;
print open (PWD, "<&" . fileno $pwd) ? "ok" : "not ok", " 7\n";
aio_stat *PWD, sub {
print -f _ ? "ok" : "not ok", " 8\n";
print +(join ":", @pwd) eq (join ":", stat _) ? "ok" : "not ok", " 9\n";
};
pcb;
aio_close *PWD, sub {
print $_[0] ? "not ok" : "ok", " 10\n";
};
pcb;
$| = 1;
if (-f "/etc/passwd" and -d "/etc") {
print "1..2\n";
} else {
print "1..0 # Skipped: unexpected /etc and/or /etc/passwd\n";
exit;
}
# relies on /etc/passwd to exist...
use Fcntl;
use IO::AIO;
IO::AIO::min_parallel 2;
sub pcb {
while (IO::AIO::nreqs) {
my $rfd = ""; vec ($rfd, IO::AIO::poll_fileno, 1) = 1; select $rfd, undef, undef, undef;
IO::AIO::poll_cb;
}
}
my $pwd;
aio_open "/etc/passwd", O_RDONLY, 0, sub {
print $_[0] ? "ok" : "not ok", " 1\n";
$pwd = $_[0];
};
pcb;
my ($sysread, $aioread);
sysseek $pwd, 7, 0;
sysread $pwd, $sysread, 15;
# I found no way to silence the stupid "uninitialized...subroutine entry" warning.
# this is just braindamaged. Don't use -w, it introduces more bugs than it fixes.
$aioread = "xxxyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy";
aio_read $pwd, 7, 15, $aioread, 3, sub {
print +($aioread eq "xxx$sysread") ? "ok" : "not ok", " 2\n";
};
pcb;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
use IO::AIO;
package aio_test_common;
use strict;
require Exporter;
use vars qw(@ISA @EXPORT);
use File::Temp ();
@ISA = qw(Exporter);
@EXPORT = qw(pcb tempdir);
sub tempdir {
return File::Temp::tempdir( CLEANUP => 1 );
}
sub pcb {
while (IO::AIO::nreqs) {
my $rfd = ""; vec ($rfd, IO::AIO::poll_fileno, 1) = 1; select $rfd, undef, undef, undef;
IO::AIO::poll_cb;
}
}
1;
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment