From fd763aa5633724de9e5c580f27ea61850a58d9b8 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 18 Aug 2009 15:22:56 -0700 Subject: rainbows: monkey-patch Rev::TCPListener for now So we can reuse our existing TCPServer objects. Patches have already been submitted (but not yet accepted) to rev for upstream inclusion here: http://rubyforge.org/pipermail/rev-talk/2009-August/000097.html --- lib/unicorn/rainbows.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/unicorn/rainbows.rb b/lib/unicorn/rainbows.rb index 39fe29c..6c9a0d6 100644 --- a/lib/unicorn/rainbows.rb +++ b/lib/unicorn/rainbows.rb @@ -92,6 +92,27 @@ module Unicorn end end +# Allow Rev::TCPListener to use an existing TCPServer +# patch already submitted: +# http://rubyforge.org/pipermail/rev-talk/2009-August/000097.html +class Rev::TCPListener + alias_method :orig_initialize, :initialize + + def initialize(addr, port = nil, options = {}) + BasicSocket.do_not_reverse_lookup = true unless options[:reverse_lookup] + options[:backlog] ||= DEFAULT_BACKLOG + + listen_socket = if ::TCPServer === addr + addr + else + raise ArgumentError, "port must be an integer" if nil == port + ::TCPServer.new(addr, port) + end + listen_socket.instance_eval { listen(options[:backlog]) } + super(listen_socket) + end +end + if $0 == __FILE__ app = lambda { |env| if /\A100-continue\z/i =~ env['HTTP_EXPECT'] -- cgit v1.2.3-24-ge0c7