From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS16276 5.135.0.0/16 X-Spam-Status: No, score=-1.7 required=3.0 tests=AWL,BAYES_00,RCVD_IN_XBL, RDNS_NONE shortcircuit=no autolearn=no version=3.3.2 X-Original-To: rainbows-public@bogomips.org Received: from 80x24.org (unknown [5.135.209.86]) by dcvr.yhbt.net (Postfix) with ESMTP id B3783203FA for ; Tue, 13 Oct 2015 23:46:00 +0000 (UTC) From: Eric Wong To: rainbows-public@bogomips.org Subject: [PATCH v2] response: convert source arg to path before IO.copy_stream Date: Tue, 13 Oct 2015 23:45:59 +0000 Message-Id: <20151013234559.21457-1-e@80x24.org> In-Reply-To: <20151010015258.19805-1-e@80x24.org> References: <20151010015258.19805-1-e@80x24.org> List-Id: 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