From 7e5942c3de1d79a6597443db5158b74c5253f6d3 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 11 Nov 2009 20:19:40 -0800 Subject: tee_input: better premature disconnect handling Just let the error bubble all the way up to where Unicorn calls process_client where it'll be appropriately handled. Additionally, we'l just check the return value of tee() in ensure_length and avoid it if it nils on us. --- lib/unicorn/tee_input.rb | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/unicorn/tee_input.rb b/lib/unicorn/tee_input.rb index 4d1ec8c..eeed7ba 100644 --- a/lib/unicorn/tee_input.rb +++ b/lib/unicorn/tee_input.rb @@ -128,13 +128,10 @@ module Unicorn # returns nil if reading from the input returns nil def tee(length, dst) unless parser.body_eof? - begin - if parser.filter_body(dst, socket.readpartial(length, buf)).nil? - @tmp.write(dst) - @tmp.seek(0, IO::SEEK_END) # workaround FreeBSD/OSX + MRI 1.8.x bug - return dst - end - rescue EOFError + if parser.filter_body(dst, socket.readpartial(length, buf)).nil? + @tmp.write(dst) + @tmp.seek(0, IO::SEEK_END) # workaround FreeBSD/OSX + MRI 1.8.x bug + return dst end end finalize_input @@ -159,8 +156,8 @@ module Unicorn # block the caller in that case. return buf if buf.nil? || @size.nil? - while buf.size < length && @size != @tmp.pos - buf << tee(length - buf.size, @buf2) + while buf.size < length && tee(length - buf.size, @buf2) + buf << @buf2 end buf -- cgit v1.2.3-24-ge0c7