From 588577cc4852f9dce1bd011451399ce96c00023c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 21 Apr 2009 11:14:52 -0700 Subject: http_response: small speedup by eliminating loop This avoids creating yet another binding. socket.syswrite() should really only be called once since we use blocking sockets, but just in case, we emulate a do+while loop with begin+while --- lib/unicorn/http_response.rb | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/unicorn/http_response.rb b/lib/unicorn/http_response.rb index b355ad4..6b6fa07 100644 --- a/lib/unicorn/http_response.rb +++ b/lib/unicorn/http_response.rb @@ -64,15 +64,12 @@ module Unicorn # write(2) can return short on slow devices like sockets as well # as fail with EINTR if a signal was caught. def self.socket_write(socket, buffer) - loop do - begin - written = socket.syswrite(buffer) - return written if written == buffer.length - buffer = buffer[written..-1] - rescue Errno::EINTR - retry - end - end + begin + written = socket.syswrite(buffer) + return written if written == buffer.length + buffer = buffer[written..-1] + rescue Errno::EINTR + end while true end end -- cgit v1.2.3-24-ge0c7