From 8b65858a864aa0ecfa24ccf8f910c36af0ec1ad6 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 6 Jul 2010 04:01:30 +0000 Subject: cleanup error handling for aborted downloads We shouldn't ever spew errors to the stderr/logger on client disconnects (ECONNRESET/EPIPE/etc...). --- lib/rainbows/fiber/body.rb | 3 --- lib/rainbows/rev/client.rb | 15 ++++++++------- lib/rainbows/rev/sendfile.rb | 2 +- lib/rainbows/writer_thread_pool.rb | 2 +- lib/rainbows/writer_thread_spawn.rb | 2 +- 5 files changed, 11 insertions(+), 13 deletions(-) (limited to 'lib') diff --git a/lib/rainbows/fiber/body.rb b/lib/rainbows/fiber/body.rb index cd6c55c..b77e310 100644 --- a/lib/rainbows/fiber/body.rb +++ b/lib/rainbows/fiber/body.rb @@ -19,9 +19,6 @@ module Rainbows::Fiber::Body # :nodoc: client.wait_writable rescue EOFError break - rescue => e - Rainbows::Error.app(e) - break end while true end else diff --git a/lib/rainbows/rev/client.rb b/lib/rainbows/rev/client.rb index e0572bb..f9284e8 100644 --- a/lib/rainbows/rev/client.rb +++ b/lib/rainbows/rev/client.rb @@ -124,13 +124,11 @@ module Rainbows return if DeferredResponse === body begin - begin - rev_sendfile(body) - rescue EOFError # expected at file EOF - @deferred_bodies.shift - body.close - close if :close == @state && @deferred_bodies.empty? - end + rev_sendfile(body) + rescue EOFError # expected at file EOF + @deferred_bodies.shift + body.close + close if :close == @state && @deferred_bodies.empty? rescue => e handle_error(e) end @@ -140,6 +138,9 @@ module Rainbows end def on_close + while f = @deferred_bodies.shift + DeferredResponse === f or f.close + end CONN.delete(self) end diff --git a/lib/rainbows/rev/sendfile.rb b/lib/rainbows/rev/sendfile.rb index 03ce41c..11cd114 100644 --- a/lib/rainbows/rev/sendfile.rb +++ b/lib/rainbows/rev/sendfile.rb @@ -14,8 +14,8 @@ module Rainbows::Rev::Sendfile def rev_sendfile(body) body.offset += @_io.sendfile_nonblock(body, body.offset, 0x10000) + enable_write_watcher rescue Errno::EAGAIN - ensure enable_write_watcher end else diff --git a/lib/rainbows/writer_thread_pool.rb b/lib/rainbows/writer_thread_pool.rb index b6c53e8..a2ef1ba 100644 --- a/lib/rainbows/writer_thread_pool.rb +++ b/lib/rainbows/writer_thread_pool.rb @@ -78,7 +78,7 @@ module Rainbows io.write(arg1) end rescue => err - Error.app(err) + Error.write(io, err) end end end diff --git a/lib/rainbows/writer_thread_spawn.rb b/lib/rainbows/writer_thread_spawn.rb index e1f9e53..9e793fc 100644 --- a/lib/rainbows/writer_thread_spawn.rb +++ b/lib/rainbows/writer_thread_spawn.rb @@ -61,7 +61,7 @@ module Rainbows io.write(arg1) end rescue => e - Error.app(e) + Error.write(io, e) end end CUR.delete(Thread.current) -- cgit v1.2.3-24-ge0c7