about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-05-28 12:00:52 -0700
committerEric Wong <normalperson@yhbt.net>2009-05-28 12:01:23 -0700
commit19cbfe209a0f9d64e9faade1549c1b9910bf35f7 (patch)
treea832553ca8f40461bb97a60c5160ba96b26fb9a4
parentbb3d776d8c07f2492ec5a3ef22184f5f59e116c7 (diff)
downloadunicorn-19cbfe209a0f9d64e9faade1549c1b9910bf35f7.tar.gz
Make us look even better in "Hello World" benchmarks!
Passing a third parameter to avoid the constant lookup
for the HttpRequest object doesn't seem to have a
measurable effect.
-rw-r--r--lib/unicorn.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/unicorn.rb b/lib/unicorn.rb
index d56cb6f..8a74f97 100644
--- a/lib/unicorn.rb
+++ b/lib/unicorn.rb
@@ -425,8 +425,8 @@ module Unicorn
 
     # 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)
-      HttpResponse.write(client, @app.call(REQUEST.read(client)))
+    def process_client(app, client)
+      HttpResponse.write(client, app.call(REQUEST.read(client)))
     # if we get any error, try to write something back to the client
     # assuming we haven't closed the socket, but don't get hung up
     # if the socket is already closed or broken.  We'll always ensure
@@ -487,6 +487,7 @@ module Unicorn
       trap(:QUIT) { alive = nil; LISTENERS.each { |s| s.close rescue nil } }
       [:TERM, :INT].each { |sig| trap(sig) { exit!(0) } } # instant shutdown
       @logger.info "worker=#{worker.nr} ready"
+      app = @app
 
       begin
         nr < 0 and reopen_worker_logs(worker.nr)
@@ -504,7 +505,7 @@ module Unicorn
 
         ready.each do |sock|
           begin
-            process_client(sock.accept_nonblock)
+            process_client(app, sock.accept_nonblock)
             nr += 1
             t == (ti = Time.now.to_i) or alive.chmod(t = ti)
           rescue Errno::EAGAIN, Errno::ECONNABORTED