about summary refs log tree commit homepage
path: root/lib/rainbows/stream_response_epoll.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2012-05-09 02:18:08 +0000
committerEric Wong <normalperson@yhbt.net>2012-05-09 02:18:08 +0000
commitbbd55c8bcd0d2833c99a2c23856ff07be7f46f9a (patch)
tree2e02524ffed199460cf3ac0d72b7869bdb94c09e /lib/rainbows/stream_response_epoll.rb
parent9573d9bc6c63aced28300a9d7346b5575eed8b7d (diff)
downloadrainbows-bbd55c8bcd0d2833c99a2c23856ff07be7f46f9a.tar.gz
unicorn 4.3.x now calls shutdown() explicitly on the socket,
so we can't just rely on a dup()-ed FD to keep a socket around.
Diffstat (limited to 'lib/rainbows/stream_response_epoll.rb')
-rw-r--r--lib/rainbows/stream_response_epoll.rb24
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/rainbows/stream_response_epoll.rb b/lib/rainbows/stream_response_epoll.rb
index ed13c05..3bb3540 100644
--- a/lib/rainbows/stream_response_epoll.rb
+++ b/lib/rainbows/stream_response_epoll.rb
@@ -67,9 +67,31 @@ module Rainbows::StreamResponseEpoll
         end while true
       end
     end
-    ep_client.close if ep_client
     ensure
       body.respond_to?(:close) and body.close
+      if ep_client
+        ep_client.close
+      else
+        socket.shutdown
+        socket.close
+      end
+  end
+
+  # once a client is accepted, it is processed in its entirety here
+  # in 3 easy steps: read request, call app, write app response
+  def process_client(client)
+    status, headers, body = @app.call(env = @request.read(client))
+
+    if 100 == status.to_i
+      client.write(Unicorn::Const::EXPECT_100_RESPONSE)
+      env.delete(Unicorn::Const::HTTP_EXPECT)
+      status, headers, body = @app.call(env)
+    end
+    @request.headers? or headers = nil
+    http_response_write(client, status, headers, body)
+  rescue => e
+    handle_error(client, e)
   end
+
   # :startdoc:
 end