From 35676cc75feb022558476be0f503ddb7e134b747 Mon Sep 17 00:00:00 2001 From: evanweaver Date: Thu, 1 Nov 2007 02:52:50 +0000 Subject: reinstate bsd accept filter git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@858 19e92222-5c0b-0410-8929-a290d50e31e9 --- lib/mongrel.rb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/mongrel.rb b/lib/mongrel.rb index 5cde698..c5d41fa 100644 --- a/lib/mongrel.rb +++ b/lib/mongrel.rb @@ -235,13 +235,21 @@ module Mongrel def configure_socket_options case RUBY_PLATFORM - when /linux/ - # 9 is currently TCP_DEFER_ACCEPT - $tcp_defer_accept_opts = [Socket::SOL_TCP, 9, 1] - $tcp_cork_opts = [Socket::SOL_TCP, 3, 1] + when /linux/ + # 9 is currently TCP_DEFER_ACCEPT + $tcp_defer_accept_opts = [Socket::SOL_TCP, 9, 1] + $tcp_cork_opts = [Socket::SOL_TCP, 3, 1] + when /freebsd(([1-4]\..{1,2})|5\.[0-4])/ + # Do nothing, just closing a bug when freebsd <= 5.4 + when /freebsd/ + # Use the HTTP accept filter if available. + # The struct made by pack() is defined in /usr/include/sys/socket.h as accept_filter_arg + unless `/sbin/sysctl -nq net.inet.accf.http`.empty? + $tcp_defer_accept_opts = [Socket::SOL_SOCKET, Socket::SO_ACCEPTFILTER, ['httpready', nil].pack('a16a240')] + end end end - + # Runs the thing. It returns the thread used so you can "join" it. You can also # access the HttpServer::acceptor attribute to get the thread later. def run -- cgit v1.2.3-24-ge0c7