From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 7AAAE20373 for ; Mon, 13 Mar 2017 19:28:45 +0000 (UTC) From: Eric Wong To: mogilefs-client-public@bogomips.org Subject: [PATCH] socket_common: limit garbage workaround to Ruby <= 2.4.1 Date: Mon, 13 Mar 2017 19:28:45 +0000 Message-Id: <20170313192845.667-1-e@80x24.org> List-Id: It looks like Ruby 2.4.1 will have the regression fixed backported to it: https://bugs.ruby-lang.org/issues/13299#change-63503 The next releases of Ruby 2.3 and 2.2 may, too; at the branch maintainer's decision. --- lib/mogilefs/socket_common.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/mogilefs/socket_common.rb b/lib/mogilefs/socket_common.rb index 212f5da..e35ae03 100644 --- a/lib/mogilefs/socket_common.rb +++ b/lib/mogilefs/socket_common.rb @@ -59,9 +59,12 @@ def readpartial(size, buf = "", timeout = 5) # Workaround for https://bugs.ruby-lang.org/issues/13085 # (excessive garbage from IO#write) # This regression was introduced in Ruby 2.0 (r34847) - # and looks like it will be fixed in Ruby 2.5 final. + # and looks like it will be fixed in Ruby 2.4.1 and Ruby 2.5 + # backport request: https://bugs.ruby-lang.org/issues/13299 + rvn = RUBY_VERSION.split('.'.freeze).map(&:to_i) # "2.4.1" => [ 2, 4, 1 ] if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ruby' && - RUBY_VERSION.to_f >= 2.0 && RUBY_VERSION.to_f <= 2.4 + rvn[0] >= 2 && + ((rvn[1] == 4 && rvn[2] == 0) || (rvn[1] < 4)) def write(buf) # Blocking TCP writes would error out long before one day, # and MogileFS won't allow file creations which take over a day. -- EW