From 0283928fca45a012b31662b30b49990dac2aae18 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 6 Jul 2010 08:53:54 +0000 Subject: rev/client: more aggressive non-blocking write non-blocking write() may cause kernel buffers to be allocated behind the scenes, so retry the write() even if it's short because it may succeed the next time around. --- lib/rainbows/rev/client.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/rainbows/rev/client.rb b/lib/rainbows/rev/client.rb index f9284e8..f854a63 100644 --- a/lib/rainbows/rev/client.rb +++ b/lib/rainbows/rev/client.rb @@ -29,18 +29,16 @@ module Rainbows begin w = @_io.write_nonblock(buf) if w == Rack::Utils.bytesize(buf) - on_write_complete - return w + return on_write_complete end # we never care for the return value, but yes, we may return # a "fake" short write from super(buf) if anybody cares. buf = buf[w..-1] rescue Errno::EAGAIN - # fall through to super(buf) + break # fall through to super(buf) rescue - close - return - end + return close + end while true end super(buf) end -- cgit v1.2.3-24-ge0c7