From e1dcadef6ca242e36e99aab19e3e040bf01070f9 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 5 Nov 2009 18:30:28 -0800 Subject: Threaded models have trouble with late loading under 1.9 Loading TeeInput or HttpResponse late does not always work well in multithreaded situations and have been causing random test failures on heavily loaded multicore boxes. --- lib/rainbows/http_server.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/rainbows/http_server.rb') diff --git a/lib/rainbows/http_server.rb b/lib/rainbows/http_server.rb index c0877cd..7935105 100644 --- a/lib/rainbows/http_server.rb +++ b/lib/rainbows/http_server.rb @@ -47,7 +47,13 @@ module Rainbows raise ArgumentError, "concurrency model #{model.inspect} not supported" extend(mod) Const::RACK_DEFAULTS['rainbows.model'] = @use = model.to_sym - Const::RACK_DEFAULTS['rack.multithread'] = !!(/Thread/ =~ model.to_s) + + if /Thread/ =~ model.to_s + Const::RACK_DEFAULTS['rack.multithread'] = true + # autoload/require is not thread-safe + Unicorn.constants.each { |x| Unicorn.const_get(x) } + end + case @use when :Rev, :EventMachine Const::RACK_DEFAULTS['rainbows.autochunk'] = true -- cgit v1.2.3-24-ge0c7