about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-11-09 17:15:58 -0800
committerEric Wong <normalperson@yhbt.net>2009-11-09 17:15:58 -0800
commit560216c2fecfc5cf3489f749dc7a0221fd78eb26 (patch)
tree13a58e30f0c12d02e40a2deeda260d0424aa607b /lib
parent27744eed51e3a21786a9e3dcd0b83937e1047f60 (diff)
downloadunicorn-560216c2fecfc5cf3489f749dc7a0221fd78eb26.tar.gz
This will benefit users of a copy-on-write-friendly memory
manager provided with Ruby Enterprise Edition.  Additionally,
this will the reduce maintenance impact on Rainbows! in the future
since load/require are not thread-safe under 1.9.
Diffstat (limited to 'lib')
-rw-r--r--lib/unicorn.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/unicorn.rb b/lib/unicorn.rb
index 7fa8468..a696402 100644
--- a/lib/unicorn.rb
+++ b/lib/unicorn.rb
@@ -725,6 +725,10 @@ module Unicorn
 
     def build_app!
       if app.respond_to?(:arity) && app.arity == 0
+        # exploit COW in case of preload_app.  Also avoids race
+        # conditions in Rainbows! since load/require are not thread-safe
+        Unicorn.constants.each { |x| Unicorn.const_get(x) }
+
         if defined?(Gem) && Gem.respond_to?(:refresh)
           logger.info "Refreshing Gem list"
           Gem.refresh