io_splice RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* [PATCH 1/2] io/splice: deprecated potentially unsafe methods
@ 2013-05-12 20:02 Eric Wong
  2013-05-12 20:02 ` [PATCH 2/2] .gitignore: add .rbx Eric Wong
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Wong @ 2013-05-12 20:02 UTC (permalink / raw)
  To: ruby.io.splice

In retrospect, these methods are too infrequently useful and
causes problems too easily to be worth supporting.
---
 lib/io/splice.rb | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/lib/io/splice.rb b/lib/io/splice.rb
index 65d8ed4..9b17aa3 100644
--- a/lib/io/splice.rb
+++ b/lib/io/splice.rb
@@ -3,6 +3,14 @@
 require 'io/wait'
 
 module IO::Splice
+  @warned = false
+
+  def self.__deprecated
+    return if @warned
+    warn("IO::Splice.{copy_stream,full} are deprecated " \
+         "and to be removed in io_splice 5.x")
+    @warned = true
+  end
 
   # The maximum default capacity of the pipe in bytes.
   # Under stock Linux, this is 65536 bytes as of 2.6.11, and 4096 before
@@ -36,10 +44,19 @@ def self.need_open?(obj) # :nodoc:
   # 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).
+  # Unlike IO.copy_stream, this does not take into account
+  # userspace I/O buffers nor IO-like objects with no underlying
+  # file descriptor (e.g. StringIO).
+  #
+  # This is unsafe for socket-to-socket copies unless there is an
+  # active (blocking) reader on the other end.
+  #
+  # This method is deprecated and will be removed in a future, as it is
+  # potentially unsafe for socket-to-socket operations and difficult-to-use.
+  # IO.copy_stream on Linux 2.6.33 and later allows using sendfile for
+  # file-to-file copies, so this offers no advantage.
   def self.copy_stream(src, dst, len = nil, src_offset = nil)
+    __deprecated
     close = []
     need_open?(src) and close << (src = File.open(src))
     need_open?(dst) and close << (dst = File.open(dst, "w"))
@@ -90,6 +107,7 @@ def self.copy_stream(src, dst, len = nil, src_offset = nil)
   #
   # This method is safe for splicing a pipe +src+ into any type of +dst+ IO.
   def self.full(src, dst, len, src_offset)
+    __deprecated
     IO.splice(src, src_offset, dst, nil, len, F_MOVE | WAITALL)
   end
 
-- 
1.8.2.1.367.gc875ca7



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] .gitignore: add .rbx
  2013-05-12 20:02 [PATCH 1/2] io/splice: deprecated potentially unsafe methods Eric Wong
@ 2013-05-12 20:02 ` Eric Wong
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2013-05-12 20:02 UTC (permalink / raw)
  To: ruby.io.splice

Newer versions of Rubinius generate files in .rbx.
---
 .gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitignore b/.gitignore
index 8054019..12e180f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@
 *.so
 *.log
 *.rbc
+.rbx
 Makefile
 /GIT-VERSION-FILE
 /local.mk
-- 
1.8.2.1.367.gc875ca7



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-05-12 20:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-12 20:02 [PATCH 1/2] io/splice: deprecated potentially unsafe methods Eric Wong
2013-05-12 20:02 ` [PATCH 2/2] .gitignore: add .rbx Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/ruby_io_splice.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).