I’m working on some middleware for rails, working with a pretty recent version:
pfernand-2-mn:~ pfernand$ rails -v
Rails 3.1.2
This is the output of rake middleware:
use ActionDispatch::Static
** use Rack::Lock **
use ActiveSupport::Cache::Strategy::LocalCache
use Rack::Runtime
use Rails::Rack::Logger
use ActionDispatch::ShowExceptions
use ActionDispatch::RemoteIp
use Rack::Sendfile
use ActionDispatch::Callbacks
use ActiveRecord::ConnectionAdapters::ConnectionManagement
use ActiveRecord::QueryCache
use ActionDispatch::Cookies
use ActionDispatch::Session::CookieStore
use ActionDispatch::Flash
use ActionDispatch::ParamsParser
use Rack::MethodOverride
use ActionDispatch::Head
use ActionDispatch::BestStandardsSupport
run MyApp::Application.routes
The thing is that the second component, Rack::Lock is, as far as I know, a mutex wrapping the whole frigging rails stack (!).
Does this mean that there’s no concurrency in rails, no matter what platform you’re using? (I’m using JRuby).
I know I can delete the lock with:
config.middleware.delete(Rack::Lock)
But sadly that breaks everything. Does that mean my app is not threadsafe?
You should see the following entry in config/environments/production.rb
Uncomment in a JRuby or other thread-friendly environment to deploy in threadsafe mode.