Changeset 858

Show
Ignore:
Timestamp:
10/31/07 21:52:50 (10 months ago)
Author:
evanweaver
Message:

reinstate bsd accept filter

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/mongrel.rb

    r852 r858  
    236236    def configure_socket_options 
    237237      case RUBY_PLATFORM 
    238         when /linux/ 
    239           # 9 is currently TCP_DEFER_ACCEPT 
    240           $tcp_defer_accept_opts = [Socket::SOL_TCP, 9, 1] 
    241           $tcp_cork_opts = [Socket::SOL_TCP, 3, 1] 
    242       end 
    243     end 
    244  
     238      when /linux/ 
     239        # 9 is currently TCP_DEFER_ACCEPT 
     240        $tcp_defer_accept_opts = [Socket::SOL_TCP, 9, 1] 
     241        $tcp_cork_opts = [Socket::SOL_TCP, 3, 1] 
     242      when /freebsd(([1-4]\..{1,2})|5\.[0-4])/ 
     243        # Do nothing, just closing a bug when freebsd <= 5.4 
     244      when /freebsd/ 
     245        # Use the HTTP accept filter if available. 
     246        # The struct made by pack() is defined in /usr/include/sys/socket.h as accept_filter_arg 
     247        unless `/sbin/sysctl -nq net.inet.accf.http`.empty? 
     248          $tcp_defer_accept_opts = [Socket::SOL_SOCKET, Socket::SO_ACCEPTFILTER, ['httpready', nil].pack('a16a240')] 
     249        end 
     250      end 
     251    end 
     252     
    245253    # Runs the thing.  It returns the thread used so you can "join" it.  You can also 
    246254    # access the HttpServer::acceptor attribute to get the thread later.