From 42402dbe14f54220ffd208e935b33c997feacd24 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 27 Jan 2017 02:53:41 +0000 Subject: avoid excessive garbage on uploads with Ruby 2.2+ This is a workaround for since we use non-blocking sockets anyways. --- lib/mogilefs/socket_common.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib/mogilefs') diff --git a/lib/mogilefs/socket_common.rb b/lib/mogilefs/socket_common.rb index 5ba8c10..9383731 100644 --- a/lib/mogilefs/socket_common.rb +++ b/lib/mogilefs/socket_common.rb @@ -56,4 +56,17 @@ module MogileFS::SocketCommon def readpartial(size, buf = "", timeout = 5) timed_read(size, buf, timeout) or raise EOFError, "end of file reached" end + + # workaround for https://bugs.ruby-lang.org/issues/13085 + # (excessive garbage from IO#write) + # XXX maybe this can be fixed for Ruby 2.5 final, but maybe not: + # Update this when Ruby 2.5 is released on 2017-12-25 + if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ruby' && + RUBY_VERSION.to_f >= 2.2 && RUBY_VERSION.to_f <= 2.5 + 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 -- cgit v1.2.3-24-ge0c7