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.
This commit is contained in:
parent
a166fb9608
commit
a7202d54cd
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue