Permalink
Browse files

Fix FCGI handler with lighttpd [#1854 state:resolved]

  • Loading branch information...
josh committed Feb 7, 2009
1 parent 2277fbe commit 2316e7dfb16518d4d0d92165bcd53b262080fc37
Showing with 6 additions and 4 deletions.
  1. +6 −4 railties/lib/fcgi_handler.rb
@@ -38,6 +38,8 @@ def initialize(log_file_path = nil, gc_request_period = nil)
# Safely install signal handlers.
install_signal_handlers
+ @app = Dispatcher.new
+
# Start error timestamp at 11 seconds ago.
@last_error_on = Time.now - 11
end
@@ -72,8 +74,8 @@ def process_each_request(provider)
cgi = nil
catch :exit do
- provider.each_cgi do |cgi|
- process_request(cgi)
+ provider.each do |request|
+ process_request(request)
case when_ready
when :reload
@@ -92,13 +94,13 @@ def process_each_request(provider)
close_connection(cgi)
end
- def process_request(cgi)
+ def process_request(request)
@processing, @when_ready = true, nil
gc_countdown
with_signal_handler 'USR1' do
begin
- ::Rack::Handler::FastCGI.serve(cgi, Dispatcher.new)
+ ::Rack::Handler::FastCGI.serve(request, @app)
rescue SignalException, SystemExit
raise
rescue Exception => error

3 comments on commit 2316e7d

nel replied Feb 10, 2009

Yep it is the good way to go josh, using the real fastcgi request as it is expected by rack and not a cgi version. I have the same kind of patch and it seems to work.

One stuff I’ve done though and which is not in that patch is to patch close_connection.

currently:

```
def close_connection(cgi)
cgi.instance_variable_get(“@request”).finish if cgi
end
```

Should be rather be according to the fcgi C gem documentation:

```
def close_connection(fcgi)
fcgi && fcgi.finish
end
```

Member

josh replied Feb 10, 2009

Nel, could you make that into a patch and submit it to LH. Thanks.

nel replied Feb 10, 2009

My mistake, you fix it in the next commit f98d8ee72b2fd

Thanks a lot Josh

Please sign in to comment.