about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-04-21 11:14:52 -0700
committerEric Wong <normalperson@yhbt.net>2009-04-21 11:16:37 -0700
commit588577cc4852f9dce1bd011451399ce96c00023c (patch)
tree7765f8228513d868507935e5cbfad4adb99eb7ae
parentb031b9d2cb1bd0434ce2891ce20a65a5b5b29796 (diff)
downloadunicorn-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
-rw-r--r--lib/unicorn/http_response.rb15
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