* [PATCH] response: convert source arg to path before IO.copy_stream
@ 2015-10-10 1:52 Eric Wong
2015-10-13 23:45 ` [PATCH v2] " Eric Wong
0 siblings, 1 reply; 2+ messages in thread
From: Eric Wong @ 2015-10-10 1:52 UTC (permalink / raw)
To: rainbows-public
This will allow us use the sendfile syscall under Linux on
Ruby which favor #read/#readpartial methods for non-IO objects.
---
lib/rainbows/response.rb | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/rainbows/response.rb b/lib/rainbows/response.rb
index 8d0de1d..5a2b0d5 100644
--- a/lib/rainbows/response.rb
+++ b/lib/rainbows/response.rb
@@ -128,6 +128,9 @@ module Rainbows::Response
unless IO.method_defined?(:trysendfile)
module CopyStream
def write_body_file(body, range)
+ # ensure sendfile gets used for SyncClose objects:
+ body = body.to_path if body.respond_to?(:to_path)
+
range ? COPY_STREAM.copy_stream(body, self, range[1], range[0]) :
COPY_STREAM.copy_stream(body, self)
end
--
EW
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH v2] response: convert source arg to path before IO.copy_stream
2015-10-10 1:52 [PATCH] response: convert source arg to path before IO.copy_stream Eric Wong
@ 2015-10-13 23:45 ` Eric Wong
0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2015-10-13 23:45 UTC (permalink / raw)
To: rainbows-public
This will allow us use the sendfile syscall under Linux on
Ruby which favor #read/#readpartial methods for non-IO objects.
This also allows us to revert changes made in
commit db790ff3531acdfa23ab290998bba29360a6782b
("sync_close: This fix breakage from Ruby-trunk r50118")
---
lib/rainbows/response.rb | 5 +++++
lib/rainbows/sync_close.rb | 8 --------
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/lib/rainbows/response.rb b/lib/rainbows/response.rb
index 8d0de1d..b7b6aa8 100644
--- a/lib/rainbows/response.rb
+++ b/lib/rainbows/response.rb
@@ -128,6 +128,11 @@ module Rainbows::Response
unless IO.method_defined?(:trysendfile)
module CopyStream
def write_body_file(body, range)
+ # ensure sendfile gets used for SyncClose objects:
+ if !body.kind_of?(IO) && body.respond_to?(:to_path)
+ body = body.to_path
+ end
+
range ? COPY_STREAM.copy_stream(body, self, range[1], range[0]) :
COPY_STREAM.copy_stream(body, self)
end
diff --git a/lib/rainbows/sync_close.rb b/lib/rainbows/sync_close.rb
index 8738cae..999f003 100644
--- a/lib/rainbows/sync_close.rb
+++ b/lib/rainbows/sync_close.rb
@@ -16,14 +16,6 @@ class Rainbows::SyncClose
@body.respond_to?(m)
end
- def readpartial(*args)
- @body.readpartial(*args)
- end
-
- def read(*args)
- @body.read(*args)
- end
-
def to_path
@body.to_path
end
--
EW
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-10-13 23:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-10 1:52 [PATCH] response: convert source arg to path before IO.copy_stream Eric Wong
2015-10-13 23:45 ` [PATCH v2] " Eric Wong
Rainbows! Rack HTTP server user/dev discussion
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://yhbt.net/rainbows-public
git clone --mirror http://ou63pmih66umazou.onion/rainbows-public
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V1 rainbows-public rainbows-public/ https://yhbt.net/rainbows-public \
rainbows-public@yhbt.net rainbows-public@bogomips.org rainbows-talk@rubyforge.org rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
public-inbox-index rainbows-public
Example config snippet for mirrors.
Newsgroups are available over NNTP:
nntp://news.public-inbox.org/inbox.comp.lang.ruby.rainbows
nntp://ou63pmih66umazou.onion/inbox.comp.lang.ruby.rainbows
note: .onion URLs require Tor: https://www.torproject.org/
code repositories for project(s) associated with this inbox:
../../../rainbows.git
AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git