copy_stream: handle and block on EAGAIN from the non-pipe IO
commit87332294a9cb7e3ce426050a7c949569200a4f01
authorEric Wong <normalperson@yhbt.net>
Sun, 6 Jun 2010 19:21:42 +0000 (6 19:21 +0000)
committerEric Wong <normalperson@yhbt.net>
Sun, 6 Jun 2010 19:39:17 +0000 (6 19:39 +0000)
tree53b00f4de220925c79c76befd34550cc79c20276
parente86706ab91e3d44297f03d1d9428968e237a1d2a
copy_stream: handle and block on EAGAIN from the non-pipe IO

splice(2) (called without SPLICE_F_NONBLOCK) only blocks on the
pipe descriptor, but may trigger EAGAIN from the non-pipe
descriptor.  So use IO.select to deal with the case where the
non-pipe descriptor is non-blocking and wait on it.

While we're at it, add the IO::Splice.partial and
IO::Splice.full singleton methods to make our life easier
to implement copy_stream with.  These methods may also
be used directly by users who may find them useful.
lib/io/splice.rb
test/test_io_splice.rb