From 133523706715b6e95d2bf410886560f21a23b1e8 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 6 Jun 2016 05:00:11 +0000 Subject: wbuf: remove tmpdir parameter We can retrieve it when we actually need to create the temporary file. This saves an ivar slot and method dispatch parameters. This patch is nice, unfortunately the patch which follows is not :P --- lib/yahns/http_response.rb | 4 ++-- lib/yahns/proxy_http_response.rb | 2 +- lib/yahns/wbuf.rb | 5 ++--- 3 files changed, 5 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/yahns/http_response.rb b/lib/yahns/http_response.rb index 531194f..d957df6 100644 --- a/lib/yahns/http_response.rb +++ b/lib/yahns/http_response.rb @@ -62,7 +62,7 @@ module Yahns::HttpResponse # :nodoc: alive = Yahns::StreamFile.new(body, alive, offset, count) body = nil end - wbuf = Yahns::Wbuf.new(body, alive, self.class.output_buffer_tmpdir) + wbuf = Yahns::Wbuf.new(body, alive) rv = wbuf.wbuf_write(self, header) if body && ! alive.respond_to?(:call) # skip body.each if hijacked body.each { |chunk| rv = wbuf.wbuf_write(self, chunk) } @@ -199,7 +199,7 @@ module Yahns::HttpResponse # :nodoc: chunk = rv # hope the skb grows when we loop into the trywrite when :wait_writable, :wait_readable if k.output_buffering - wbuf = Yahns::Wbuf.new(body, alive, k.output_buffer_tmpdir) + wbuf = Yahns::Wbuf.new(body, alive) rv = wbuf.wbuf_write(self, chunk) break else diff --git a/lib/yahns/proxy_http_response.rb b/lib/yahns/proxy_http_response.rb index 61f1539..8de5b4f 100644 --- a/lib/yahns/proxy_http_response.rb +++ b/lib/yahns/proxy_http_response.rb @@ -21,7 +21,7 @@ module Yahns::HttpResponse # :nodoc: def wbuf_alloc(req_res) if req_res.proxy_pass.proxy_buffering - Yahns::Wbuf.new(nil, req_res.alive, self.class.output_buffer_tmpdir) + Yahns::Wbuf.new(nil, req_res.alive) else Yahns::WbufLite.new(req_res) end diff --git a/lib/yahns/wbuf.rb b/lib/yahns/wbuf.rb index 1010c86..583df10 100644 --- a/lib/yahns/wbuf.rb +++ b/lib/yahns/wbuf.rb @@ -32,9 +32,8 @@ class Yahns::Wbuf # :nodoc: include Yahns::WbufCommon attr_reader :busy - def initialize(body, persist, tmpdir) + def initialize(body, persist) @tmpio = nil - @tmpdir = tmpdir @sf_offset = @sf_count = 0 @wbuf_persist = persist # whether or not we keep the connection alive @body = body # something we call #close on when done writing @@ -58,7 +57,7 @@ class Yahns::Wbuf # :nodoc: @busy = rv end until @busy - @tmpio ||= Yahns::TmpIO.new(@tmpdir) + @tmpio ||= Yahns::TmpIO.new(c.class.output_buffer_tmpdir) @sf_count += String === buf ? @tmpio.write(buf) : wbuf_writev(buf) # we spent some time copying to the FS, try to write to -- cgit v1.2.3-24-ge0c7