Permalink
Browse files

Introduce native mongrel handler and push mutex into dispatcher.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8488 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent f013e04 commit e2d4ebdea4eab41c4af1c5530a9e180d11529dec @jeremy jeremy committed Dec 27, 2007
@@ -2,6 +2,8 @@ module ActionController
# Dispatches requests to the appropriate controller and takes care of
# reloading the app after each request when Dependencies.load? is true.
class Dispatcher
+ @@guard = Mutex.new
+
class << self
# Backward-compatible class method takes CGI-specific args. Deprecated
# in favor of Dispatcher.new(output, request, response).dispatch.
@@ -111,12 +113,16 @@ def initialize(output, request = nil, response = nil)
end
def dispatch
- run_callbacks :before
- handle_request
- rescue Exception => exception
- failsafe_rescue exception
- ensure
- run_callbacks :after, :reverse_each
+ @@guard.synchronize do
+ begin
+ run_callbacks :before
+ handle_request
+ rescue Exception => exception
+ failsafe_rescue exception
+ ensure
+ run_callbacks :after, :reverse_each
+ end
+ end
end
def dispatch_cgi(cgi, session_options)
View
@@ -1,5 +1,7 @@
*SVN*
+* Introduce native mongrel handler and push mutex into dispatcher. [Jeremy Kemper]
+
* Ruby 1.9 compatibility. #1689, #10546 [Cheah Chu Yeow, frederico]
@@ -18,7 +18,11 @@
ARGV.shift
else
if defined?(Mongrel)
- "mongrel"
+ if Mongrel.respond_to?(:log)
+ "new_mongrel"
+ else
+ "mongrel"
+ end
elsif RUBY_PLATFORM !~ /(:?mswin|mingw)/ && !silence_stderr { `lighttpd -version` }.blank? && defined?(FCGI)
"lighttpd"
else
@@ -31,7 +35,7 @@
puts "=> Booting WEBrick..."
when "lighttpd"
puts "=> Booting lighttpd (use 'script/server webrick' to force WEBrick)"
- when "mongrel"
+ when "mongrel", "new_mongrel"
puts "=> Booting Mongrel (use 'script/server webrick' to force WEBrick)"
end
@@ -0,0 +1,16 @@
+unless defined?(Mongrel)
+ abort "PROBLEM: Mongrel is not available on your system (or not in your path)"
+end
+
+require 'rails/mongrel_server/commands'
+
+GemPlugin::Manager.instance.load "rails::mongrel" => GemPlugin::INCLUDE, "rails" => GemPlugin::EXCLUDE
+
+case ARGV[0] ||= 'start'
+when 'start', 'stop', 'restart'
+ ARGV[0] = "rails::mongrelserver::#{ARGV[0]}"
+end
+
+if not Mongrel::Command::Registry.instance.run ARGV
+ exit 1
+end
Oops, something went wrong.

0 comments on commit e2d4ebd

Please sign in to comment.