From 679a4b4673f66a299322facfe2acb8776bf61c00 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 18 Jun 2010 09:44:57 +0000 Subject: rev: cleanup write method I was originally experimenting with setsockopt to increase the kernel buffer sizes in a loop, but the benefits were negligible at best. --- lib/rainbows/rev/client.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/rainbows/rev/client.rb b/lib/rainbows/rev/client.rb index 788d8c8..e51ccdc 100644 --- a/lib/rainbows/rev/client.rb +++ b/lib/rainbows/rev/client.rb @@ -21,22 +21,20 @@ module Rainbows def write(buf) if @_write_buffer.empty? - rv = buf.size # try to write directly to the kernel socket buffers to avoid an # extra userspace copy if possible. begin w = @_io.write_nonblock(buf) - if w == buf.size + if w == buf.bytesize on_write_complete - return rv + return w end buf = buf[w..-1] rescue Errno::EAGAIN - break # copy what's left into the IO::Buffer rescue close return - end while true + end end super(buf) end -- cgit v1.2.3-24-ge0c7