about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-12-04 00:58:45 -0800
committerEric Wong <normalperson@yhbt.net>2009-12-04 01:03:36 -0800
commitf8ba20423edbe23acb772a9e908d9695ebd92d56 (patch)
treeeddd8aab63d5610bc68ae2889e42fb664e60c046
parenta3df52bd02d9dae07492db6394d574462bd80768 (diff)
downloadrainbows-f8ba20423edbe23acb772a9e908d9695ebd92d56.tar.gz
It may make it harder to switch between concurrency models with
SIGHUP this way...
-rw-r--r--lib/rainbows/rev/core.rb3
-rw-r--r--lib/rainbows/rev/deferred_response.rb8
2 files changed, 4 insertions, 7 deletions
diff --git a/lib/rainbows/rev/core.rb b/lib/rainbows/rev/core.rb
index 1d667cc..90857a2 100644
--- a/lib/rainbows/rev/core.rb
+++ b/lib/rainbows/rev/core.rb
@@ -7,7 +7,6 @@ module Rainbows
   module Rev
     class Server < ::Rev::IO
       G = Rainbows::G
-      LOOP = ::Rev::Loop.default
       # CL and MAX will be defined in the corresponding worker loop
 
       def on_readable
@@ -25,10 +24,10 @@ module Rainbows
       def worker_loop(worker)
         init_worker_process(worker)
         mod = self.class.const_get(@use)
+        rloop = Server.const_set(:LOOP, ::Rev::Loop.default)
         Server.const_set(:MAX, @worker_connections)
         Server.const_set(:CL, mod.const_get(:Client))
         EvCore.setup(EvCore)
-        rloop = ::Rev::Loop.default
         Heartbeat.new(1, true).attach(rloop)
         LISTENERS.map! { |s| Server.new(s).attach(rloop) }
         rloop.run
diff --git a/lib/rainbows/rev/deferred_response.rb b/lib/rainbows/rev/deferred_response.rb
index 9c3c27f..b69c7be 100644
--- a/lib/rainbows/rev/deferred_response.rb
+++ b/lib/rainbows/rev/deferred_response.rb
@@ -10,10 +10,6 @@ module Rainbows
       G = Rainbows::G
       HH = Rack::Utils::HeaderHash
 
-      # we only want to attach to the Rev::Loop belonging to the
-      # main thread in Ruby 1.9
-      LOOP = ::Rev::Loop.default
-
       def self.defer!(client, response, out)
         body = response.last
         headers = HH.new(response[1])
@@ -36,7 +32,9 @@ module Rainbows
             out[0] = CONN_CLOSE
           end
 
-          io = new(io, client, do_chunk, body).attach(LOOP)
+          # we only want to attach to the Rev::Loop belonging to the
+          # main thread in Ruby 1.9
+          io = new(io, client, do_chunk, body).attach(Server::LOOP)
         elsif st.file?
           headers.delete('Transfer-Encoding')
           headers['Content-Length'] ||= st.size.to_s