From: Eric Wong <e@80x24.org>
To: rainbows-public@bogomips.org
Subject: [PATCH] response: convert source arg to path before IO.copy_stream
Date: Sat, 10 Oct 2015 01:52:58 +0000 [thread overview]
Message-ID: <20151010015258.19805-1-e@80x24.org> (raw)
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
next reply other threads:[~2015-10-10 1:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-10 1:52 Eric Wong [this message]
2015-10-13 23:45 ` [PATCH v2] response: convert source arg to path before IO.copy_stream 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/rainbows/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151010015258.19805-1-e@80x24.org \
--to=e@80x24.org \
--cc=rainbows-public@bogomips.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/rainbows.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).