From a7202d54cdedffac6cbd06cd37f2f6ef98c31204 Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Fri, 18 Dec 2009 11:45:26 -0600 Subject: [PATCH] Workaround Ruby 1.9.1 tempfile Bug Add a patch (from Passenger 2.2.8) to vendored Rack, which works around a bug in Ruby 1.9.1. This patch to Rack has been floating around the intertubes for a while. --- .../vendor/rack-1.1.pre/rack/rewindable_input.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.1.pre/rack/rewindable_input.rb b/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.1.pre/rack/rewindable_input.rb index 2347dc35..2864d510 100644 --- a/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.1.pre/rack/rewindable_input.rb +++ b/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.1.pre/rack/rewindable_input.rb @@ -72,7 +72,7 @@ module Rack # access it because we have the file handle open. @rewindable_io = Tempfile.new('RackRewindableInput') @rewindable_io.chmod(0000) - if filesystem_has_posix_semantics? + if filesystem_has_posix_semantics? && !tempfile_unlink_contains_bug? @rewindable_io.unlink @unlinked = true end @@ -94,5 +94,15 @@ module Rack def filesystem_has_posix_semantics? RUBY_PLATFORM !~ /(mswin|mingw|cygwin|java)/ end + + def tempfile_unlink_contains_bug? + # The tempfile library as included in Ruby 1.9.1-p152 and later + # contains a bug: unlinking an open Tempfile object also closes + # it, which breaks our expected POSIX semantics. This problem + # has been fixed in Ruby 1.9.2, but the Ruby team chose not to + # include the bug fix in later versions of the 1.9.1 series. + ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby" + ruby_engine == "ruby" && RUBY_VERSION == "1.9.1" && RUBY_PATCHLEVEL >= 152 + end end end