diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-06-27 15:58:45 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-06-29 04:04:27 -0700 |
commit | 14ce889cc12628405b0f6a1842b7e1ad09ca4b7b (patch) | |
tree | 2188c1bdb823209bd6bfaeeda249af74f99b7920 /lib/unicorn/tee_input.rb | |
parent | 665717d9d339748447e26d3eb0e34c9f6c64ce73 (diff) | |
download | unicorn-14ce889cc12628405b0f6a1842b7e1ad09ca4b7b.tar.gz |
The complexity of making the object persistent isn't worth the potential performance gain here.
Diffstat (limited to 'lib/unicorn/tee_input.rb')
-rw-r--r-- | lib/unicorn/tee_input.rb | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/lib/unicorn/tee_input.rb b/lib/unicorn/tee_input.rb index 9e66837..ac9638d 100644 --- a/lib/unicorn/tee_input.rb +++ b/lib/unicorn/tee_input.rb @@ -15,30 +15,16 @@ require 'tempfile' module Unicorn class TeeInput - def initialize - @rd = @wr = @size = @input = nil - setup - end - - def setup - @tmp = tmp = Tempfile.new(nil) - @rd.close if @rd - @rd = File.open(tmp.path, 'wb+') - @wr.close if @wr - @wr = File.open(tmp.path, 'wb') + def initialize(input, size = nil, buffer = nil) + @wr = Tempfile.new(nil) + @wr.binmode + @rd = File.open(@wr.path, 'rb') + @wr.unlink @rd.sync = @wr.sync = true - tmp.close! - end - - def reopen(input, size = nil, buffer = nil) - @rd.seek(0) - @wr.seek(0) - @rd.truncate(0) # truncate read to flush luserspace read buffers @wr.write(buffer) if buffer @input = input @size = size # nil if chunked - self end def consume |