From: Eric Wong <normalperson@yhbt.net>
To: ruby.io.splice@librelist.org
Subject: [PATCH 1/2] io/splice: deprecated potentially unsafe methods
Date: Sun, 12 May 2013 20:02:55 +0000 [thread overview]
Message-ID: <1368388976-20489-1-git-send-email-normalperson@yhbt.net> (raw)
In-Reply-To: <1368388976-20489-1-git-send-email-normalperson@yhbt.net>
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
next parent reply other threads:[~2013-05-12 20:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-12 20:02 Eric Wong [this message]
2013-05-12 20:02 ` [PATCH 2/2] .gitignore: add .rbx Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://yhbt.net/ruby_io_splice/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1368388976-20489-1-git-send-email-normalperson@yhbt.net \
--to=normalperson@yhbt.net \
--cc=ruby.io.splice@librelist.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).