@busy will be reset on wbuf_write anyways, since there is no
initial data and we will always attempt to write to the socket
aggressively.
---
lib/yahns/http_response.rb | 8 ++++----
lib/yahns/proxy_http_response.rb | 8 ++++----
lib/yahns/wbuf.rb | 4 ++--
test/test_wbuf.rb | 8 ++++----
4 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/lib/yahns/http_response.rb b/lib/yahns/http_response.rb
index 4b36db2..531194f 100644
--- a/lib/yahns/http_response.rb
+++ b/lib/yahns/http_response.rb
@@ -57,12 +57,12 @@ def err_response(code)
"#{response_start}#{code} #{Rack::Utils::HTTP_STATUS_CODES[code]}\r\n\r\n"
end
- def response_header_blocked(ret, header, body, alive, offset, count)
+ def response_header_blocked(header, body, alive, offset, count)
if body.respond_to?(:to_path)
alive = Yahns::StreamFile.new(body, alive, offset, count)
body = nil
end
- wbuf = Yahns::Wbuf.new(body, alive, self.class.output_buffer_tmpdir, ret)
+ wbuf = Yahns::Wbuf.new(body, alive, self.class.output_buffer_tmpdir)
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) }
@@ -171,7 +171,7 @@ def http_response_write(status, headers, body)
when :wait_writable, :wait_readable # unlikely
if k.output_buffering
alive = hijack ? hijack : alive
- rv = response_header_blocked(rv, buf, body, alive, offset, count)
+ rv = response_header_blocked(buf, body, alive, offset, count)
body = nil # ensure we do not close body in ensure
return rv
else
@@ -199,7 +199,7 @@ def http_response_write(status, headers, body)
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, rv)
+ wbuf = Yahns::Wbuf.new(body, alive, k.output_buffer_tmpdir)
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 ea176d9..61f1539 100644
--- a/lib/yahns/proxy_http_response.rb
+++ b/lib/yahns/proxy_http_response.rb
@@ -19,9 +19,9 @@ def proxy_unbuffer(wbuf)
:ignore
end
- def wbuf_alloc(req_res, busy)
+ def wbuf_alloc(req_res)
if req_res.proxy_pass.proxy_buffering
- Yahns::Wbuf.new(nil, req_res.alive, self.class.output_buffer_tmpdir,
busy)
+ Yahns::Wbuf.new(nil, req_res.alive, self.class.output_buffer_tmpdir)
else
Yahns::WbufLite.new(req_res)
end
@@ -37,7 +37,7 @@ def proxy_write(wbuf, buf, req_res)
when String, Array # partial write, hope the skb grows
buf = rv
when :wait_writable, :wait_readable
- wbuf = req_res.resbuf ||= wbuf_alloc(req_res, rv)
+ wbuf = req_res.resbuf ||= wbuf_alloc(req_res)
break
end while true
end
@@ -75,7 +75,7 @@ def proxy_err_response(code, req_res, exc)
end
def wait_on_upstream(req_res)
- req_res.resbuf ||= wbuf_alloc(req_res, false)
+ req_res.resbuf ||= wbuf_alloc(req_res)
:wait_readable # self remains in :ignore, wait on upstream
end
diff --git a/lib/yahns/wbuf.rb b/lib/yahns/wbuf.rb
index f7b2ffa..1010c86 100644
--- a/lib/yahns/wbuf.rb
+++ b/lib/yahns/wbuf.rb
@@ -32,13 +32,13 @@ class Yahns::Wbuf # :nodoc:
include Yahns::WbufCommon
attr_reader :busy
- def initialize(body, persist, tmpdir, busy)
+ def initialize(body, persist, tmpdir)
@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
- @busy = busy # may be false
+ @busy = false
end
def wbuf_writev(buf)
diff --git a/test/test_wbuf.rb b/test/test_wbuf.rb
index 1c8c0d0..990ad9d 100644
--- a/test/test_wbuf.rb
+++ b/test/test_wbuf.rb
@@ -20,8 +20,8 @@ def test_wbuf
buf = "*" * (16384 * 2)
nr = 1000
[ true, false ].each do |persist|
- wbuf = Yahns::Wbuf.new([], persist, Dir.tmpdir, :wait_writable)
- assert_equal :wait_writable, wbuf.busy
+ wbuf = Yahns::Wbuf.new([], persist, Dir.tmpdir)
+ assert_equal false, wbuf.busy
a, b = socketpair
assert_nil wbuf.wbuf_write(a, "HIHI")
assert_equal "HIHI", b.read(4)
@@ -71,7 +71,7 @@ def test_wbuf_blocked
break
end while true
end
- wbuf = Yahns::Wbuf.new([], true, Dir.tmpdir, :wait_writable)
+ wbuf = Yahns::Wbuf.new([], true, Dir.tmpdir)
rv1 = wbuf.wbuf_write(a, buf)
rv2 = wbuf.wbuf_flush(a)
@@ -104,7 +104,7 @@ def test_wbuf_blocked
def test_wbuf_flush_close
pipe = cloexec_pipe
persist = true
- wbuf = Yahns::Wbuf.new(pipe[0], persist, Dir.tmpdir, :wait_writable)
+ wbuf = Yahns::Wbuf.new(pipe[0], persist, Dir.tmpdir)
refute wbuf.respond_to?(:close) # we don't want this for HttpResponse body
sp = socketpair
rv = nil
--
unsubscribe: [email protected]
archive: https://yhbt.net/yahns-public/