about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-05-01 13:58:23 -0700
committerEric Wong <normalperson@yhbt.net>2011-05-01 14:08:26 -0700
commit5e544bc745e5216f2455fa0ad398e39097debe60 (patch)
tree41a28e7dea4812c13626e4d678d5e1d1a08a48f6
parentb5ec116e331c22c064bee46f63145e325785e33f (diff)
downloadruby_io_splice-5e544bc745e5216f2455fa0ad398e39097debe60.tar.gz
IO::Splice.copy_stream is more useful, now
-rw-r--r--README6
-rw-r--r--lib/io/splice.rb6
2 files changed, 9 insertions, 3 deletions
diff --git a/README b/README
index de64627..b2a8b4b 100644
--- a/README
+++ b/README
@@ -12,11 +12,13 @@ buffer.
 
 * More flexible than sendfile, may be used to enable copies between
   arbitrary file descriptors (assuming kernel support), not just
-  socket-to-file.
+  file-to-socket (or file-to-anything in newer Linux).
 
 * Thread-safe blocking operations under Ruby 1.9, releases GVL
   if blocking operations are used.
 
+* Almost drop-in replacement for IO.copy_stream: IO::Splice.copy_stream
+
 * Safely usable with non-blocking I/O frameworks (unlike IO.copy_stream)
   when combined with the IO::Splice::F_NONBLOCK flag.
 
@@ -72,7 +74,7 @@ You can get the latest source via git from the following locations:
 You may browse the code from the web and download the latest snapshot
 tarballs here:
 
-* http://bogomips.org/cgit/ruby_io_splice.git (cgit)
+* http://bogomips.org/ruby_io_splice.git (cgit)
 * http://repo.or.cz/w/ruby_io_splice.git (gitweb)
 
 Inline patches (from "git format-patch") to the mailing list are
diff --git a/lib/io/splice.rb b/lib/io/splice.rb
index 2dd88b9..4ec44e4 100644
--- a/lib/io/splice.rb
+++ b/lib/io/splice.rb
@@ -29,6 +29,10 @@ module IO::Splice
   # +EOFError+ is raised if fewer than +len+ bytes could be copied.
   # Otherwise the copy will be until EOF is reached on the +src+.
   # +src+ and +dst+ must be IO objects or respond to +to_io+
+  #
+  # This is nearly a drop-in replacement for IO.copy_stream (in Ruby 1.9)
+  # but does not take into account userspace I/O buffers nor IO-like
+  # objects with no underlying file descriptor (e.g. StringIO).
   def self.copy_stream(src, dst, len = nil, src_offset = nil)
     close = []
     src.kind_of?(String) and close << (src = File.open(src))
@@ -102,7 +106,7 @@ module IO::Splice
   end
 
   # returns an array suitable for splat-ing to IO.select for blocking I/O
-  def self.selectable(src, dst)
+  def self.selectable(src, dst) # :nodoc:
     rv = []
     src.stat.pipe? or rv[0] = [ src ]
     dst.stat.pipe? or rv[1] = [ dst ]