about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-02-10 10:58:33 -0800
committerEric Wong <normalperson@yhbt.net>2009-02-10 10:58:33 -0800
commit36573963a235fd1016ce978667ab83eb40011061 (patch)
treefc7ebf6da0c30985e44904997cd4648e807c8aef /lib
parent7bbbd1dda0cd38882629e1fc317070e5a9068c5b (diff)
downloadunicorn-36573963a235fd1016ce978667ab83eb40011061.tar.gz
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/unicorn.rb5
1 files changed, 3 insertions, 2 deletions
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)}"