about summary refs log tree commit homepage
path: root/lib/rainbows/event_machine.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-05-04 13:47:11 -0700
committerEric Wong <normalperson@yhbt.net>2010-05-04 13:50:25 -0700
commit52b306c5cd47e34644f7ec5f7ab100855929b618 (patch)
tree47b4782443754573dfad3815807e361dda69e616 /lib/rainbows/event_machine.rb
parente8cedc2584d23a8ab214ff96a973dc37344c2796 (diff)
downloadrainbows-52b306c5cd47e34644f7ec5f7ab100855929b618.tar.gz
Since deferred requests run in a separate thread, this affects
the root (non-deferred) thread as well since it may share
data with other threads.
Diffstat (limited to 'lib/rainbows/event_machine.rb')
-rw-r--r--lib/rainbows/event_machine.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/rainbows/event_machine.rb b/lib/rainbows/event_machine.rb
index 4b852c9..b19bdec 100644
--- a/lib/rainbows/event_machine.rb
+++ b/lib/rainbows/event_machine.rb
@@ -209,6 +209,14 @@ module Rainbows
     # This middleware is automatically loaded by Rainbows! when using
     # EventMachine and if the app responds to the +deferred?+ method.
     class TryDefer < Struct.new(:app)
+
+      def initialize(app)
+        # the entire app becomes multithreaded, even the root (non-deferred)
+        # thread since any thread can share processes with others
+        Const::RACK_DEFAULTS['rack.multithread'] = true
+        super
+      end
+
       def call(env)
         if app.deferred?(env)
           EM.defer(proc { catch(:async) { app.call(env) } },