ThingFish/DeveloperNotes: mongrel_handlers_process.patch

File mongrel_handlers_process.patch, 1.4 kB (added by mgranger, 1 year ago)

Mongrel patch to break out a critical piece of process_client()

  • lib/mongrel.rb

    old new  
    613613              # request is good so far, continue processing the response 
    614614              response = HttpResponse.new(client) 
    615615 
    616               # Process each handler in registered order until we run out or one finalizes the response. 
    617               handlers.each do |handler| 
    618                 handler.process(request, response) 
    619                 break if response.done or client.closed? 
    620               end 
     616              process_handlers(client, handlers, request, response) 
    621617 
    622618              # And finally, if nobody closed the response off, we finalize it. 
    623619              unless response.done or client.closed?  
     
    658654      end 
    659655    end 
    660656 
     657    # Process each handler in registered order until we run out or one finalizes the  
     658    # response. 
     659    def process_handlers(client, handlers, request, response) 
     660        handlers.each do |handler| 
     661          handler.process(request, response) 
     662          return if response.done or client.closed? 
     663        end 
     664    end 
     665     
     666 
    661667    # Used internally to kill off any worker threads that have taken too long 
    662668    # to complete processing.  Only called if there are too many processors 
    663669    # currently servicing.  It returns the count of workers still active