This release fixes compatibility with Ruby trunk r44955 and onwards. There are also numerous cleanups. Note: usage of IO::Splice::WAITALL is deprecated and will be removed in 5.x along with IO::Splice.copy_stream.
We now limit maximum splice length to (1<<30) to avoid EINVAL errors on 64-bit hosts. vmsplice no longer raises Errno::EFAULT optimizations in newer GCC (not that I've found a good use for vmsplice at all with Ruby...) There are several other small cleanups. Eric Wong (6): copy_stream: small cleanup for pipe splicing limit maximum splice length to 1 << 30 avoid uname() for pipe size modification checks doc: s/librelist.com/librelist.org/ vmsplice: avoid referencing invalid stack address for strings vmsplice: more consistent fileno retry handling
IO::Splice.copy_stream now uses SPLICE_F_NONBLOCK whenever the destination is a pipe. Our documentation is also updated to reflect the issue of splicing from sockets into pipes. ref: http://lkml.org/lkml/2009/1/13/478
IO::Splice.copy_stream coerces based on the availability of the #to_path method in source and destination arguments. This is to be compatible with IO.copy_stream and also Rack::File since this may be used in web servers. This is NOT visible with Ruby 1.8 since File.open doesn't coerce with #to_path on the given object.
Methods now automatically retry on EINTR after checking IO#closed? and executing interrupts. There is a new IO::Splice::WAITALL flag (implemented in userspace) which may be used to cause IO.splice and IO.tee to retry (while the GVL is released) until the operation is complete. IO::Splice.copy_stream now works correctly for large copies if source offset is specified. MRI 1.8 is only weakly supported now, MRI 1.9 is the preferred platform though Rubinius appears to work, too.
IO::Splice.copy_stream no longer modifies the actual file offset of the given source file (if it's a regular file). This follows IO.copy_stream and IO#sendfile semantics, allowing multiple threads/processes to simultaneously stream a single regular file descriptor to multiple sockets/pipes.
This release adds the IO.trysplice and IO.trytee interfaces to avoid expensive EAGAIN exceptions for non-blocking I/O. There is no IO.tryvmsplice method as we still haven't figured out a good use for IO.vmsplice in Ruby, and non-blocking I/O with iovecs is just painful! If you want more zero-copy fun without needing mmap(2), check out the "sendfile" RubyGem and IO.copy_stream (1.9). As of Linux 2.6.33+, sendfile(2) can copy mmap-able files to +any+ descriptor, not just sockets. Please email us at firstname.lastname@example.org if you can think of a good use for IO.vmsplice or IO.trysplice in Ruby.
This release adds IO#pipe_size and IO#pipe_size= accessors for resizing the kernel pipe buffer under Linux 2.6.35+. This functionality may be used to either reduce memory footprint or make large copies with fewer method dispatches and system calls. These methods are only available when run under Linux 2.6.35 or later (but always built, so there's no need to recompile this library after upgrading your kernel). http://bogomips.org/ruby_io_splice/doc/IO.html#method-i-pipe_size http://bogomips.org/ruby_io_splice/doc/IO.html#method-i-pipe_size%3D
This fixes the issue with our copy_stream where non-pipe descriptors with the O_NONBLOCK flag set were not handled correctly. Like IO.copy_stream in Ruby 1.9, our IO::Splice.copy_stream will _always_ block until IO is available (or raise if there are errors). IO::Splice.copy_stream now closes all file descriptors that were opened within the method, reducing pressure on the garbage collector. There are also new singleton convenience methods: * IO::Splice.full - blocks and splices the full amount * IO::Splice.partial - blocks until something is spliceable They are used internally to implement IO::Splice.copy_stream, but may also be useful to end users. Rcov shows 100% test coverage \o/
There is a new IO::Splice.copy_stream method which is similar to the IO.copy_stream method in 1.9 core, but uses splice() internally to avoid copies to userspace in situations where sendfile() is not possible. With Linux 2.6.35 (and header files to match), we will also export the F_GETPIPE_SZ and and F_SETPIPE_SZ constants so they can be used with fcntl() to resize pipe buffers. The documentation is also updated to reflect the returned usefulness of the IO::Splice::F_MOVE constant for FUSE filesystems under Linux 2.6.35. I've also relicensed to LGPLv2.1+ (from LGPLv3-only) to allow bundling with GPLv2-only applications (I'm currently the sole copyright holder). Signed-off-by: Eric Wong <email@example.com>