From 36573963a235fd1016ce978667ab83eb40011061 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 10 Feb 2009 10:58:33 -0800 Subject: Allow listen_backlog to be specified in config. This controls the backlog argument to the listen(2) system call. See your operating system documentation for listen(2) on the specifics of this option. The default is 1024, which is the same as Mongrel. 5 is the default for Ruby TCPServer and UNIXServer; and in some case it can be better where failover to a different machine/cluster is properly configured. --- lib/unicorn.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/unicorn.rb b/lib/unicorn.rb index 90c5d86..8b15da7 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -47,6 +47,7 @@ module Unicorn server.logger.info("worker=#{worker_nr} spawning...") }, :pid_file => nil, + :listen_backlog => 1024, } Worker = Struct.new(:nr, :tempfile) unless defined?(Worker) @@ -105,7 +106,7 @@ module Unicorn # try binding new listeners @listeners.map! do |addr| - if sock = bind_listen(addr, 1024) + if sock = bind_listen(addr, @listen_backlog) sock elsif inherited.empty? || addr[0..0] == "/" raise Errno::EADDRINUSE, "couldn't bind #{addr}" @@ -134,7 +135,7 @@ module Unicorn # Allows workers to add a private, per-process listener via the # @after_fork hook. Very useful for debugging and testing. def add_listener(address) - if io = bind_listen(address, 1024) + if io = bind_listen(address, @listen_backlog) @purgatory << io io = server_cast(io) logger.info "adding listener #{io} addr=#{sock_name(io)}" -- cgit v1.2.3-24-ge0c7