diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-04-21 11:14:52 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-04-21 11:16:37 -0700 |
commit | 588577cc4852f9dce1bd011451399ce96c00023c (patch) | |
tree | 7765f8228513d868507935e5cbfad4adb99eb7ae /lib/unicorn/http_response.rb | |
parent | b031b9d2cb1bd0434ce2891ce20a65a5b5b29796 (diff) | |
download | unicorn-588577cc4852f9dce1bd011451399ce96c00023c.tar.gz |
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
Diffstat (limited to 'lib/unicorn/http_response.rb')
-rw-r--r-- | lib/unicorn/http_response.rb | 15 |
1 files 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 |