Ruby mogilefs-client dev/users discussion/patches/bugs/help/...
 help / color / mirror / code / Atom feed
* [PATCH] socket_common: limit garbage workaround to Ruby <= 2.4.1
@ 2017-03-13 19:28 Eric Wong
  2017-03-23  0:29 ` Eric Wong
  2017-03-23  1:40 ` [PATCH] socket_common: improve readability of case statement Eric Wong
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Wong @ 2017-03-13 19:28 UTC (permalink / raw)
  To: mogilefs-client-public

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] socket_common: limit garbage workaround to Ruby <= 2.4.1
  2017-03-13 19:28 [PATCH] socket_common: limit garbage workaround to Ruby <= 2.4.1 Eric Wong
@ 2017-03-23  0:29 ` Eric Wong
  2017-03-23  1:40 ` [PATCH] socket_common: improve readability of case statement Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2017-03-23  0:29 UTC (permalink / raw)
  To: mogilefs-client-public

Eric Wong <e@80x24.org> wrote:
> It looks like Ruby 2.4.1 will have the regression fixed
> backported to it:
> 
> https://bugs.ruby-lang.org/issues/13299#change-63503

And it did!  2.4.1 is out and no longer needs this workaround:

https://www.ruby-lang.org/en/news/2017/03/22/ruby-2-4-1-released/

> The next releases of Ruby 2.3 and 2.2 may, too; at the
> branch maintainer's decision.

Haven't seen any movement in that direction, yet.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] socket_common: improve readability of case statement
  2017-03-13 19:28 [PATCH] socket_common: limit garbage workaround to Ruby <= 2.4.1 Eric Wong
  2017-03-23  0:29 ` Eric Wong
@ 2017-03-23  1:40 ` Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2017-03-23  1:40 UTC (permalink / raw)
  To: mogilefs-client-public

Due to the release of Ruby 2.4.1 with the necessary fix,
it seems likely that future releases (if any) of the 2.2
and 2.3 series will avoid garbage on IO#write, too.
---
 lib/mogilefs/socket_common.rb | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/lib/mogilefs/socket_common.rb b/lib/mogilefs/socket_common.rb
index ec9249f..53771c8 100644
--- a/lib/mogilefs/socket_common.rb
+++ b/lib/mogilefs/socket_common.rb
@@ -59,16 +59,21 @@ 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.4.1 and Ruby 2.5
+  # and it is fixed in Ruby 2.4.1+
   # 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' &&
-     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.
-      timed_write(buf, 86400)
+    case RUBY_VERSION
+    when '2.0.0',
+         '2.1.0'..'2.1.9',
+         # we expect 2.2.7 and 2.3.4 to not need this
+         '2.2.0'..'2.2.6',
+         '2.3.0'..'2.3.3',
+         '2.4.0' # 2.4.1 is good!
+      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.
+        timed_write(buf, 86400)
+      end
     end
   end
 end
-- 
EW

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-03-23  1:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-13 19:28 [PATCH] socket_common: limit garbage workaround to Ruby <= 2.4.1 Eric Wong
2017-03-23  0:29 ` Eric Wong
2017-03-23  1:40 ` [PATCH] socket_common: improve readability of case statement Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/mogilefs-client.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).